PHP中的ASP.Net API消耗

时间:2016-01-13 09:43:35

标签: php asp.net api integration

大家好,                因为我是PHP新手,但我在ASP.Net方面有很好的经验。我想将我用PHP开发的网站与我的ASP.net项目和SQL Server集成。为此,我开发了一个API,并在PHP中调用它,这对我不起作用。请指导我失踪的地方。 PHP源代码如下。

$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, 'http://msplhe.ddns.net:1440/tracking/usercon/sms/89410032056412647926/31.49976>/74.36318/');
//curl_setopt ($ch, CURLOPT_URL, 'www.google.com.pk');
curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; CrOS x86_64 7520.63.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36');
    curl_setopt ($ch, CURLOPT_USERAGENT, 'cURL crawler');
    curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
    curl_setopt ($ch, CURLOPT_AUTOREFERER, true);
    curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 2);
    $html = curl_exec($ch);
    echo $html;

当我在服务器上执行此操作时,它没有显示任何结果且页面上没有错误。但是,当我评论我的API并取消注释www.google.com.pk时,它会显示谷歌搜索我的页面。我被困在里面。请帮我。 提前谢谢。

1 个答案:

答案 0 :(得分:0)

问题,我认为是网址中的> - 这导致了应用程序错误(您可以更改错误页面)btw

$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, 'http://msplhe.ddns.net:1440/tracking/usercon/sms/89410032056412647926/31.49976/74.36318/'); /* Remove ">" from url here */
curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; CrOS x86_64 7520.63.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36');
curl_setopt ($ch, CURLOPT_USERAGENT, 'cURL crawler');
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION,true);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt ($ch, CURLOPT_AUTOREFERER, true);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 2);
$html = curl_exec($ch);
curl_close( $ch );/* don't forget to close curl */
echo $html;

output
------
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Done</string>