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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With