2016-01-13 89 views
-7

即時嘗試將PHP文件轉換爲C#。問題是我不知道等效的.net命令來捲曲。將php轉換爲c#,捲曲爲.net

ob_start(); 
$ret = curl_exec($ch); 
$content = ob_get_contents(); 
ob_end_clean(); 
$rescode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 
curl_close($ch); 

我試圖找到所有這些信息,但小麥我發現只是破碎的代碼位不兼容。

+1

SO不是一個「轉換我的代碼」的服務是從Postman一個例子。請務必前往[旅遊](http://stackoverflow.com/tour)以更好地瞭解SO的工作方式以及適合的問題。 – Epodax

+1

可能已經在這裏回答http://stackoverflow.com/questions/7929013/making-a-curl-call-in-c-sharp –

+0

如果你想在C#中實現一些功能,那麼學習和編寫一些C#代碼將是一個開始的好地方。你想要實現哪些特定的功能?什麼阻止你這麼做? – David

回答

0

不指定任何東西,甚至沒有,如果它是一個GET或POST,但這種使用restsharp

var client = new RestClient("https://google.com"); 
var request = new RestRequest(Method.GET); 
request.AddHeader("postman-token", "49bab31b-6be2-5862-e3ca-351cb8b35d86"); 
request.AddHeader("cache-control", "no-cache"); 
IRestResponse response = client.Execute(request);