2016-07-06 13 views
0

Ich bin ein ziemlich seltsames Verhalten bekommen, und ich habe keine Ahnung, wie es um mehr Informationen zu erhalten, was los ist ...Curl reagiert mit einer leeren Zeichenfolge. Wie bekomme ich mehr Informationen?

I Paypal Express Checkout mit NVP-API bin. Grundsätzlich sende ich eine Anfrage und Paypal antwortet mit key1=value1&key2=value2...

Ich sende eine erste Anfrage mit Curl, alles geht gut.

Dann sende ich die nächste Anfrage mit curl, aber die $result ist leer. Aber was ist komisch, wenn ich die $paypal_url drucke und es in einen Browser kopiere/einfüge, bekomme ich die richtige Antwort.

So scheint es, dass curl sendet die Anfrage nicht, aber ich verstehe nicht warum. Wie kann ich den Austausch zwischen Curl und Paypal ausspionieren? Oder wie bekomme ich mehr Informationen darüber, was vor sich geht?

Danke!

//First request (fine) : Get Paypal Checkout Details 
$paypal_url = $url."?VERSION=204.0&USER=".$user."&PWD=".$pwd."&SIGNATURE=".$signature."&METHOD=GetExpressCheckoutDetails&TOKEN=".$token; 
$curl = curl_init(); 
curl_setopt($curl, CURLOPT_URL, $paypal_url); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($curl, CURLOPT_COOKIESESSION, true); 
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); 
$result = curl_exec($curl); 
curl_close($curl); 

//parse the result 
parse_str($result); 

//Check data integrity (nothing relevant) 
if($ACK!="Success" || $token!=$TOKEN || $amount!=$PAYMENTREQUEST_0_AMT || $currency!=$PAYMENTREQUEST_0_CURRENCYCODE) { 
    header("HTTP/1.0 402 Payment Required"); 
    die("Couldn't realize the payment checkout : ".$ACK." ".$TOKEN." required: ".$PAYMENTREQUEST_0_AMT." ".$PAYMENTREQUEST_0_CURRENCYCODE."<br/>".$token." payed : ".$amount." ".$currency); 
} 

//Second request : Do Paypal checkout 
$paypal_url = $url; 
$paypal_url .= "?VERSION=204.0"; 
$paypal_url .= "&USER=".$user; 
$paypal_url .= "&PWD=".$pwd; 
$paypal_url .= "&SIGNATURE=".$signature; 
$paypal_url .= "&METHOD=DoExpressCheckoutPayment"; 
$paypal_url .= "&TOKEN=".$token; 
$paypal_url .= "&PAYERID=".$payerid; 
$paypal_url .= "&PAYMENTREQUEST_0_PAYMENTACTION=Sale"; 
$paypal_url .= "&PAYMENTREQUEST_0_AMT=".$amount; 
$paypal_url .= "&PAYMENTREQUEST_0_CURRENCYCODE=".$currency; 
$paypal_url .= "&PAYMENTREQUEST_0_ITEMAMT =".$amount; 

$curl = curl_init(); 
curl_setopt($curl, CURLOPT_URL, $paypal_url); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($curl, CURLOPT_COOKIESESSION, true); 
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); 
$result = curl_exec($curl); 
curl_close($curl); 

//Display the URL and the result... But the result is missing ! 
die($paypal_url."\n".$result); 

//If I now copy/paste the content of $paypal_url into a browser, I get the expected result. 

Antwort

1

aktivieren ausführlichen Modus in ROTATION ...

curl_setopt($curl, CURLOPT_VERBOSE, true); 

... und haben einen Blick auf die Daten übertragen/empfangen

+0

ich nur zum Glück mein Problem gelöst: Es ist ein Raum, vor dem gleichen in PAYMENTREQUEST_0_ITEMAMT =. Ich denke, dass es zu einem Crash kam, aber nicht zum Browser. Wie auch immer, meine Frage war "wie man mehr Details bekommt" und Sie antworten perfekt. Vielen Dank ! – Sharcoux

+0

richtig, CURL mag keine Leerzeichen in der URL, der Text nach diesem Leerzeichen wird als weiterer Befehlszeilenparameter analysiert) –