我需要将这个PHP代码转换为C#.是否有工具或网站可以实现这一目标?
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;
}
Run Code Online (Sandbox Code Playgroud)
RQD*_*QDQ 39
我不知道任何可以从PHP转换为C#的工具.如果有这样的事情,我不相信它能正确地进行转换.这样就可以选择:
不要转换(这会导致无法管理的意大利面条式代码),而是使用我们正在处理的 PHP 编译器使 PHP 项目成为常规的 .NET 项目(如 F# 或 C++/CLI):
https://github.com/iolevel/peachpie
这样,除此之外,您还可以保持 PHP 代码的可维护性,同时可以从 C# 无缝使用它。
一些资源:
| 归档时间: |
|
| 查看次数: |
59092 次 |
| 最近记录: |