Answered Bing Webmaster api SubmitUrl error.

  • Saturday, January 05, 2013 4:24 AM
     
      Has Code

    Hi All,

    Reference by http://msdn.microsoft.com/en-us/library/jj554133.aspx I tried with code below but got error

    == PHP code ==================

    $request_url = 'https://ssl.bing.com/webmaster/api.svc/json/SubmitUrl?apikey=apikey';

    $request_body = '{"siteUrl":"http:\/\/example.com","url":"http:\/\/example.com\/url1.html"}';

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $request_url);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $request_body);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    $response=curl_exec($ch);
    curl_close($ch);

    var_dump($response);

    == Response ==================

    HTTP/1.1 400 Bad Request
    Cache-Control: no-cache
    Pragma: no-cache
    Content-Type: application/json; charset=utf-8
    Content-Encoding: gzip
    Expires: -1
    Content-Length: 67
    Vary: Accept-Encoding
    Date: Thu, 20 Dec 2012 08:58:15 GMT
    Connection: close

    What is the problem?

    Thanks a lot!

All Replies