Vote count:
0
Currently I have a code in PHP as below which I want to convert it to c#.
var ch = curl_init();
curl_setopt(ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt(ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt(ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt(ch, CURLOPT_COOKIEJAR, $cookie_file);
switch ($method) {
case 'POST':
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
break;
case 'PUT':
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Length: ' . strlen($data)));
break;
case 'DELETE':
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Length: ' . strlen($data)));
break;
case 'GET':
if ($data) {
$url .= '/&' . $data;
}
break;
default:
die('Invalid Method: ' . $method);
}
/* set the curl URL */
curl_setopt($ch, CURLOPT_URL, $url);
/* execute and grab the return data */
return $out = curl_exec($ch);
asked 40 secs ago
Aucun commentaire:
Enregistrer un commentaire