我需要将此PHP代码转换为C#。有没有一种工具或网站可以使这成为可能?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;
}
这似乎是一个更大的东西的一部分。你需要翻译什么?卷曲部分? – 2011-03-07 15:45:00
相关:http:// stackoverflow。com/questions/441161/how-to-convert-code-from-c-to-php – RQDQ 2011-03-07 15:45:30
可能不是你要找的,但Facebook的HipHop for PHP将PHP转换为C++。 (是的,我知道你在问C#,但这是我能想到的最接近的东西:D)。如果这就是你所追求的目标,它并不能真正帮你转换代码,但会提高你的性能。 – Sondre 2011-03-07 15:55:33