我正在尝试使用Web服务,并通过PHP cURL发布帖子。当我通过ie使用webservice时。提琴手的反应很好,但通过我的PHP脚本,我得到的只是500 - 内部服务器错误。谁能告诉我我错过了什么?
Page:http://badmintonpeople.dk/DBF/Spiller/VisSpiller/#88555
使用按钮“vælgspiller” - 你有web服务: 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);
}
}
}
提前谢谢!