Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php to C# converter [closed]

Tags:

c#

php

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;
}
like image 819
SOF User Avatar asked Mar 07 '11 15:03

SOF User


1 Answers

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.
like image 102
RQDQ Avatar answered Sep 24 '22 08:09

RQDQ