1

My xampp wont load anything on this, I tried it on gearhost, same thing, but on one other free host, it worked.. json was loaded as it should.

Here's the code

$username= urlencode($_GET["username"]);
$endpoint = 'https://api.ebay.com/ws/api.dll';
// create the xml request that will be POSTed
$xml = '<?xml version="1.0" encoding="utf-8"?>';
$xml .= '<GetStoreRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
$xml .= '<RequesterCredentials>';
$xml .= '<eBayAuthToken></eBayAuthToken>';
$xml .= '</RequesterCredentials>';
$xml .= '<UserID>'. $username .'</UserID>';
$xml .='<LevelLimit>1</LevelLimit>';
$xml .= '</GetStoreRequest>';
$headers = array(
     'X-EBAY-API-COMPATIBILITY-LEVEL:933',
'X-EBAY-API-DEV-NAME:--',
'X-EBAY-API-APP-NAME:--',
'X-EBAY-API-CERT-NAME:--',
'X-EBAY-API-SITEID:0',
'X-EBAY-API-CALL-NAME:GetStore'
    );

    $session  = curl_init($endpoint);                     
  curl_setopt($session, CURLOPT_POST, true);             
  curl_setopt($session, CURLOPT_HTTPHEADER, $headers);    
  curl_setopt($session, CURLOPT_POSTFIELDS, $xml); 
  curl_setopt($session, CURLOPT_RETURNTRANSFER, true);   
  $responsexml = curl_exec($session);                   
  curl_close($session);  

     $json = json_encode(simplexml_load_string($responsexml),true);
     $obj = json_decode($json,true);
    echo $responsexml; 
    echo $obj;
4
  • you're simply assuming curl never fails. if ($responsexml === false) { die(curl_error($session)); } Commented Aug 21, 2015 at 16:33
  • nothing.. blank page.. only when I echo $json i get "false" thats all Commented Aug 21, 2015 at 16:35
  • the thing is.. it works on some free hosting.. but not on my xampp.. or my realhosting.. Commented Aug 21, 2015 at 16:37
  • @MarcB Tried it.. still blank page.. Could it be hosting related issue? I mean it must be.. since same code runs on byethost. I contacted support they told me curl is active. Commented Aug 21, 2015 at 16:48

1 Answer 1

1

try this:

$compatabilityLevel = 859;     
$return_api_host = 'https://api.ebay.com/ws/api.dll';
$callName = 'GetStore'; //this is changed based on what call you are making

$headers = array(
    'Content-Type: text/xml',
    'X-EBAY-API-COMPATIBILITY-LEVEL: '.$compatabilityLevel,
    'X-EBAY-API-DEV-NAME: '.$devID,
    'X-EBAY-API-APP-NAME: '.$appID,
    'X-EBAY-API-CERT-NAME: '.$certID,
    'X-EBAY-API-CALL-NAME: '.$callName,
    'X-EBAY-API-SITEID: 0',
    'SOAPAction: "run"');


    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $return_api_host);
    curl_setopt($curl, CURLOPT_VERBOSE, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curl,CURLOPT_CONNECTTIMEOUT, 0);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $xmlpost);
    //get response from server
    $response =curl_exec($curl);
    //format response in array
    $responsexml = new SimpleXMLElement($response);

obviously the $xmlpost element will include your xml being sent. and you can do a print_r($responsexml) to see results.

Sign up to request clarification or add additional context in comments.

8 Comments

A little explanation of what you added and why would probably help the OP more than just giving them the code
well this is working code i use for ebay so i think this would help. i think the difence is in the curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); and curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
@md123 tried adding those two, still blank page. It seems to me it might be hosting related problem. But the tech support guy claims curl is active. This same code wont run on my local machine but it is on some 3rd server I tried..
Dont tell me Put it in your answer. Remember this answer can be seen by others that may have the same problem. Each of whom may also give it an upvote if it is a good well put together answer that explains why these extra parameters are needed in this situation.
@perkes456 i dont see you pointing your curl to a server..? try adding curl_setopt($curl, CURLOPT_URL, $return_api_host);
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.