代码之家  ›  专栏  ›  技术社区  ›  Raviraj

Paypal令牌错误

  •  0
  • Raviraj  · 技术社区  · 11 年前

    我正在设置Paypal订阅-首先我创建令牌,我的示例代码可以在这里看到:

    function testing(){
    
         $urltoken = "https://api.sandbox.paypal.com/v1/oauth2/token";
    
               $header_token = array(
                   'Accept'=>'application/json',
                   'Accept-Language'=>'en_US',
    
               );
    
               $request_body_token = array(
                   'client_id'=>'xxxxxxxxxxxxxxxxxxxxxx',
                   'secret'=>'xxxxxxxxxxxxxxxxxxxx',
                   'grant_type'=>'client_credentials',
    
    
    
               );
    
                 $take_from_token = wp_remote_request($urltoken, array('method' => 'POST', 'timeout' => 20, 'headers' => $header_token,'body'=>$request_body_token)); 
    
                 var_dump($take_from_token);  
    

    }

    这是我得到的响应错误:

    array(5) { ["headers"]=> array(8) { ["server"]=> string(17) "Apache-Coyote/1.1" ["proxy_server_info"]=> string(57) "host=slcsbplatformapiserv3001.slc.paypal.com;threadId=850" ["paypal-debug-id"]=> string(13) "09c6fcdc16b91" ["server_info"]=> string(139) "identitysecuretokenserv:v1.oauth2.token&CalThreadId=133&TopLevelTxnStartTime=14c459ad0be&Host=slcsbidensectoken502.slc.paypal.com&pid=28506" ["date"]=> string(29) "Mon, 23 Mar 2015 07:48:35 GMT" ["content-type"]=> string(16) "application/json" ["content-length"]=> string(2) "75" ["connection"]=> string(5) "close" } ["body"]=> string(75) "{"error":"invalid_client","error_description":"Invalid client credentials"}" ["response"]=> array(2) { ["code"]=> int(401) ["message"]=> string(12) "Unauthorized" } ["cookies"]=> array(0) { } ["filename"]=> NULL } 
    
    1 回复  |  直到 11 年前
        1
  •  0
  •   hlh3406    11 年前

    尝试将参数“mode”设置为“live”。如果这被设置为默认值,那么它将使用“沙盒”,并且不能使用实时凭据。

    否则,尝试通过cURL运行此测试:

    curl -v -u "client_id:test" "https://api.sandbox.paypal.com/v1/oauth2/token" -X POST -d "response_type=token&grant_type=client_credentials"
    

    记住用自己的id替换客户端id(上面的测试)。

    推荐文章