title: PHP cURL post gives internal server error?
body: <p>I am trying to use a webservice, and do a post through PHP cURL. When I use the webservice through ie. fiddler the response is fine, but through my php script, I get nothing but 500 - internal server error. Can anyone tell me what I am missing?</p>
  
  <p>Page: <a href="http://badmintonpeople.dk/DBF/Spiller/VisSpiller/#88555" rel="nofollow">http://badmintonpeople.dk/DBF/Spiller/VisSpiller/#88555</a> </p>
  
  <p>use the button "vælg spiller" - there you have the webservice:
  <a href="http://badmintonpeople.dk/SportsResults/Components/WebService1.asmx/SearchPlayer" rel="nofollow">http://badmintonpeople.dk/SportsResults/Components/WebService1.asmx/SearchPlayer</a></p>
  
  <p>In fiddler I get a fine response 200:
  dl.dropboxusercontent.com/u/885897/fiddler.jpg</p>
  
  <p>But with the code below, I get nothing... Can anyone tell me why? :-/</p>
  
  <pre><code>$urltopost = "http://badmintonpeople.dk/SportsResults/Components/WebService1.asmx/SearchPlayer";
      $data = array (
        "callbackcontextkey" =&gt; "7CF866FEDDD42B1529DAED8272DA83AF72EFBB896E3176EFB70CD34D02A81BF647D420A3F880C10178E804AC21CA4999",
        "selectfunction" =&gt; "SPSel1",
        "name" =&gt; "",
        "clubid" =&gt; "1600",
        "playernumber" =&gt; "",
        "gender" =&gt; "",
        "agegroupid" =&gt; "",
        "searchteam" =&gt; false,
        "agegroupcontext" =&gt; 0,
        "tournamentdate" =&gt; "",
      );                                                                   
  
  $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; 
  </code></pre>
  
  <p>UPDATE:
  Response is this:
  {"Message":"There was an error processing the request.","StackTrace":"","ExceptionType":""}</p>
  
  <p>Bonus info. A friend of mine made the post work in seconds in .NET with this code, but I can not imagine, that PHP can't do this job?</p>
  
  <p>.NET Console Application</p>
  
  <pre><code>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);
          }
      }
  }
  </code></pre>
  
  <p>Thank you in advance!</p>