2013-07-05 90 views
1

在使用Live憑證在本地主機上成功測試我的支付請求後,我在線移動了應用程序。Paypal PHP Curl沒有任何返回

然而,在實時服務器上,curl請求並沒有給我任何迴應,甚至沒有提供任何錯誤消息。這是完全相同的請求,在本地主機上完美工作。

$url = 'curl -s --insecure -H "X-PAYPAL-SECURITY-USERID: '.$userId.'" -H "X-PAYPAL-SECURITY-PASSWORD: '.$password.'" -H "X-PAYPAL-SECURITY-SIGNATURE: '.$signature.'" -H "X-PAYPAL-REQUEST-DATA-FORMAT: JSON" -H "X-PAYPAL-RESPONSE-DATA-FORMAT: JSON" -H "X-PAYPAL-APPLICATION-ID: '.$applicationId.'" https://svcs.paypal.com/AdaptivePayments/Pay -d "{\"actionType\":\"PAY\", \"currencyCode\":\"'.$currency.'\", \"receiverList\":{\"receiver\":[{\"amount\":\"'.$amount.'\",\"email\":\"'.$receiverEmail.'\"}]}, \"returnUrl\":\"'.$successUrl.'\", \"cancelUrl\":\"'.$failUrl.'\", \"requestEnvelope\":{\"errorLanguage\":\"en_US\", \"detailLevel\":\"ReturnAll\"}}'; 
$result = json_decode(exec($url)); 

現在就是PHP。我試圖在命令行中運行curl請求。在本地主機上,我立即得到正確的回報。在現場服務器上,我首先得到一個「>」符號,如果我再次粘貼命令並輸入,它會給我一些輸出。

{"responseEnvelope":{"timestamp":"2013-07-05T13:16:26.305-07:00","ack":"Failure","correlationId":"2b8ab6998078e","build":"6520082"},"error":[{"errorId":"580001","domain":"PLATFORM","subdomain":"Application","severity":"Error","category":"Application","message":"Invalid request: {0}"}]} 

奇怪的是,這個工程對本地主機,但不能直播服務器上,所以我想,這一定是在PHP,捲曲或服務器設置一些區別......但我真的沒有一個線索。

回答

1

echo $ url的輸出是什麼?

你爲什麼要通過exec運行curl?爲什麼不使用mod_curl?

例如...

$API_Endpoint = ""; 
    if ($sandbox) { 
     $API_Endpoint = "https://svcs.sandbox.paypal.com/AdaptivePayments"; 
    } 
    else{ 
     $API_Endpoint = "https://svcs.paypal.com/AdaptivePayments"; 
    } 

    $API_Endpoint .= "/" . $methodName; 

    //setting the curl parameters. 
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, $API_Endpoint); 
    curl_setopt($ch, CURLOPT_VERBOSE, 1); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_POST, 1); 

    // Set the HTTP Headers 
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'X-PAYPAL-REQUEST-DATA-FORMAT: NV', 
    'X-PAYPAL-RESPONSE-DATA-FORMAT: NV', 
    'X-PAYPAL-SECURITY-USERID: '. $API_UserName, 
    'X-PAYPAL-SECURITY-PASSWORD: '. $API_Password, 
    'X-PAYPAL-SECURITY-SIGNATURE: '. $API_Signature, 
    'X-PAYPAL-APPLICATION-ID: '. $API_AppID 
)); 

    // RequestEnvelope fields 
    $detail_level = urlencode("ReturnAll"); // See DetailLevelCode in the WSDL for valid enumerations 
    $error_language = urlencode("en_US"); // This should be the standard RFC 3066 language identification tag, e.g., en_US 

    // NVPRequest for submitting to server 
    $nvp_req = "requestEnvelope.errorLanguage=$error_language&requestEnvelope.detailLevel=$detail_level"; 
    $nvp_req .= "&$nvp_str"; 

    //setting the nvp_req as POST FIELD to curl 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvp_req); 

    //getting response from server 
    $response = curl_exec($ch);