0

当我得到第二个调用响应时,它直接打印了 state:created 输出但是,我如何存储直接打印自己的信息?我想重定向用户或至少将其发送到 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...

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

4

1 回答 1

0

不得不把 RETURNTRANSFER 和 VERBOSE

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

完毕。

虽然没有人回复,但如果有人遇到这个问题,请留言。有几种方法可以解决这个问题。

于 2013-08-28T08:10:17.183 回答