PHP来C#转换器 [英] php to C# converter

查看:1786
本文介绍了PHP来C#转换器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要转换为C#这个PHP代码。是否有工具或一个网站,使之成为可能?



 公共函数调用($方法,数组$ params)方法{$ b $B∥加上format参数,只有JSON此刻
如果支持(!array_key_exists('形式',$ params)方法){
$ PARAMS ['形式'] =' JSON';
}

$ URL ={$这个 - > _url} / {$方法};
$ CH = $这个 - > _getCurlHandle($网址);

如果(!$ CH){
抛出新Fuze_Client_Exception(无法创建一个卷曲的句柄);
}

//设置请求参数
$ =的queryString http_build_query($ params)方法;
curl_setopt($ CH,CURLOPT_POSTFIELDS,$的queryString);

//火!
$结果= $这个 - > _executeCurl($ CH);

//所有API响应的有效载荷应符合代码和
//消息成员
$ JSON = json_decode($结果)有效的JSON;
如果(($ JSON的instanceof stdClass的)
||使用isset($ json-> !!!代码)
||使用isset($ json->消息)){

抛出新Fuze_Client_ServerException(
无效的JSON有效载荷收到$结果,$信息['HTTP_CODE']);
}

如果($ json->代码> = 500安培;&安培; $ json->代码< 600){
抛出新Fuze_Client_FaultException($ JSON );
}

$回报JSON;
}


解决方案

我不知道任何工具,可以转换从PHP到C#。如果有这样的事情,我不相信它正确地进行转换。这样让你的选项:




  • 学习C#

  • 将它传递给谁可以把它转换


I need this PHP code converted to C#. Is there a tool or a website that would make this possible?

public function call($method, array $params) {
    // Add the format parameter, only 'json' is supported at the moment
    if (!array_key_exists('format', $params)) {
        $params['format'] = 'json';
    }

    $url = "{$this->_url}/{$method}";
    $ch = $this->_getCurlHandle($url);

    if (!$ch) {
        throw new Fuze_Client_Exception("Unable to create a cURL handle");
    }

    // Set the request parameters
    $queryString = http_build_query($params);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $queryString);

    // Fire!
    $result = $this->_executeCurl($ch);

    // All API response payloads should be valid json with 'code' and
    // 'message' members
    $json = json_decode($result);
    if ( !($json instanceof stdClass)
            || !isset($json->code)
            || !isset($json->message) ) {

        throw new Fuze_Client_ServerException(
            "Invalid JSON payload received", $result, $info['http_code']);
    }

    if ( $json->code >= 500 && $json->code < 600) {
        throw new Fuze_Client_FaultException($json);
    }

    return $json;
}

解决方案

I don't know of any tool that can convert from PHP to C#. If there is such a thing, I wouldn't trust it to do the conversion correctly. So that leaves your options to:

  • Learn C#
  • Pass it to someone who can convert it.

这篇关于PHP来C#转换器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆