1

我正在尝试使用网络服务,并通过 PHP cURL 发布帖子。当我通过 ie 使用 web 服务时。提琴手的响应很好,但是通过我的 php 脚本,我只得到 500 - 内部服务器错误。谁能告诉我我错过了什么?

页面:http ://badmintonpeople.dk/DBF/Spiller/VisSpiller/#88555

使用按钮“vælg splasher” - 你有网络服务:http: //badmintonpeople.dk/SportsResults/Components/WebService1.asmx/SearchPlayer

在提琴手中,我得到了很好的响应 200:dl.dropboxusercontent.com/u/885897/fiddler.jpg

但是使用下面的代码,我什么也得不到……谁能告诉我为什么?:-/

$urltopost = "http://badmintonpeople.dk/SportsResults/Components/WebService1.asmx/SearchPlayer";
    $data = array (
      "callbackcontextkey" => "7CF866FEDDD42B1529DAED8272DA83AF72EFBB896E3176EFB70CD34D02A81BF647D420A3F880C10178E804AC21CA4999",
      "selectfunction" => "SPSel1",
      "name" => "",
      "clubid" => "1600",
      "playernumber" => "",
      "gender" => "",
      "agegroupid" => "",
      "searchteam" => false,
      "agegroupcontext" => 0,
      "tournamentdate" => "",
    );                                                                   

$data_string = json_encode($data);                                                                                   

$ch = curl_init('http://badmintonpeople.dk/SportsResults/Components/WebService1.asmx/SearchPlayer');                                                                      
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                                                                  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
'Content-Type: application/json',                                                                                
'Content-Length: ' . strlen($data_string))                                                                       
);  
$result = curl_exec($ch);
echo $result; 

更新:响应是这样的:{"Message":"处理请求时出错。","StackTrace":"","ExceptionType":""}

奖金信息。我的一个朋友用这段代码在 .NET 中几秒钟内完成了这篇文章,但我无法想象 PHP 不能完成这项工作?

.NET 控制台应用程序

class Program
    {
        static void Main(string[] args)
        {
            const string URI = "http://badmintonpeople.dk/SportsResults/Components/WebService1.asmx/SearchPlayer";
        const string myParameters = "{'callbackcontextkey':'874DB247192F515BC3735AD164D4350C6DD5A0CFD186112C97A41B3B9FE97F81637FBEF0AEDF4A5939481BAFFFBD0A99','selectfunction':'SPSel1','name':'','clubid':'1600','playernumber':'','gender':'','agegroupid':'','searchteam':false,'agegroupcontext':0,'tournamentdate':''}";

        using (var wc = new WebClient())
        {
            wc.Headers[HttpRequestHeader.ContentType] = "application/json; charset=UTF-8";
            string HtmlResult = wc.UploadString(URI, myParameters);
        }
    }
}

先感谢您!

4

0 回答 0