PHP Curl 转C# libcurl 或C#代码, PHP POST 提交XML转C#×

PHP代码

 $account = 'abc';
$password = 'abc123';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.fdd.com/new_orders.php/");
curl_setopt($ch, CURLOPT_USERPWD, "$account.':'.$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);//CURLAUTH_ANY
curl_setopt($ch, CURLOPT_PROXY,'127.0.0.1:8888');//设置代理服务器 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('xml_request' => "$xml_request"));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: close'));
$result = curl_exec($ch);// 执行并获取HTML文档内容

curl_close($ch);// 释放curl句柄


header( "Content-Type: text/xml; charset=UTF-8");
echo $result; 

需要转成C# libCurl 或C#代码,

网上 很少C# libCrul资料,没数据返回,请指点

 Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL);
        Easy easy = new Easy();
        Easy.WriteFunction wf = new Easy.WriteFunction(OnWriteData);
        easy.SetOpt(CURLoption.CURLOPT_URL, URL);
        easy.SetOpt(CURLoption.CURLOPT_USERPWD, Account + ":" + password);
        easy.SetOpt(CURLoption.CURLOPT_HTTPAUTH,"0" );
        easy.SetOpt(CURLoption.CURLOPT_SSL_VERIFYPEER, false);
        easy.SetOpt(CURLoption.CURLOPT_TIMEOUT, "4");
        easy.SetOpt(CURLoption.CURLOPT_POST, true);
        easy.SetOpt(CURLoption.CURLOPT_POSTFIELDS, XMLData);
        easy.SetOpt(CURLoption.CURLOPT_HTTPHEADER, "Content-Type: text/xml; charset=UTF-8");
        easy.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION, wf);
        //easy.SetOpt(CURLoption.CURLOPT_POST, ture);
        easy.Perform();

        easy.Cleanup();
        Curl.GlobalCleanup();

直接给C#代码参考,不胜感激

1个回答

用fiddler抓包,然后照着写。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问