如何在Paypal通话期间重定向到approval_url?

时间:2013-08-27 20:40:08

标签: cakephp paypal

当我得到第二个呼叫响应时,它直接打印状态:创建输出但是,如何存储直接打印的信息? 我想重定向用户或至少将它发送到rel = post URL但是,当我保存输出时,它只给出值-1。

$URL = 'https://api.sandbox.paypal.com/v1/oauth2/token';
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $URL);
        curl_setopt($ch, CURLOPT_VERBOSE, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_USERPWD, "user:password");
        curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials");
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Accept: application/json'
            , 'Accept-Language: en_US'
        ));
        $response = curl_exec($ch);
        $objRes = json_decode($response);
        $appId = $objRes->app_id;
        $accessToken = $objRes->access_token;
        $tokenType = $objRes->token_type;
        $ch2 = curl_init();
        curl_setopt($ch2, CURLOPT_URL, 'https://api.sandbox.paypal.com/v1/payments/payment');
        curl_setopt($ch2, CURLOPT_HTTPHEADER, array(
            "Content-Type:application/json",
            "Authorization:$tokenType $accessToken"
        ));
        curl_setopt($ch2, CURLOPT_POSTFIELDS, $this->_generateJSON());
        $value = curl_exec($ch2);
      //$value = 1...

到目前为止,$ value的值是1 ......

有关如何重定向用户的任何猜测?

1 个答案:

答案 0 :(得分:0)

必须放置RETURNTRANSFER和VERBOSE

curl_setopt($ch2, CURLOPT_VERBOSE, 0);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_POST, true);

完成。

虽然没有人回复,但是如果有人遇到这个问题,请记下消息。有几种方法可以解决这个问题。