2017-02-05 4 views
0

こんにちは私はこの仕事のCURL投稿要求を持っています。しかし、私は400 Bad Requestで失敗しています。誰も私が間違ってやっているかを見る:PHP CURLスクリプトをおしゃべりに変換するのに助けが必要

$response = $this->getHttpClient()->post(
     'https://login.eveonline.com/oauth/token', [ 
     'headers' => [ 
      'Authorization' => 'Basic '.base64_encode(
       env('EVEONLINE_CLIENT_ID').':'.env('EVEONLINE_CLIENT_SECRET') 
      ) 
     ], 
     'grant_type' => 'refresh_token', 
     'refresh_token' => $refresh_token, 
    ]); 

    return json_decode($response->getBody()->getContents(), true); 

    /* 
    $c = curl_init(); 
    $cver = curl_version(); 
    $contact = '[email protected]';  
    curl_setopt($c, CURLOPT_URL, 'https://login.eveonline.com/oauth/token'); 
    curl_setopt($c, CURLOPT_USERAGENT, "asite/admin (curl/{$cver['version']}; {$contact})"); 
    curl_setopt($c, CURLOPT_SSL_VERIFYPEER, FALSE); 
    curl_setopt($c, CURLOPT_SSL_VERIFYHOST, FALSE); 
    curl_setopt($c, CURLOPT_POST, true); 
    curl_setopt($c, CURLOPT_RETURNTRANSFER, true); 
    curl_setopt($c, CURLOPT_POSTFIELDS, http_build_query([ 
     'grant_type' => 'refresh_token', 
     'refresh_token' => $refresh_token, 
    ])); 
    curl_setopt($c, CURLOPT_HTTPHEADER, [ 'Authorization: Basic '.base64_encode(
     env('EVEONLINE_CLIENT_ID').':'.env('EVEONLINE_CLIENT_SECRET') 
    ) ]); 

    $rawjson = curl_exec($c); 
    return json_decode($rawjson, true); 
    */ 

応答: クライアントエラー:POST https://login.eveonline.com/oauth/token400 Bad Request応答の結果: { "エラー": "INVALID_REQUEST"、 "しましたerror_description": "不明grant_type"}

+0

グズルのバージョンは? – ceejayoz

+0

https://github.com/guzzle/psr7 1.3.1リリース –

答えて

0

ご迷惑をおかけして申し訳ありません。

$response = $this->getHttpClient()->post(
     'https://login.eveonline.com/oauth/token', [ 
     'headers' => [ 
      'Authorization' => 'Basic '.base64_encode(
       env('EVEONLINE_CLIENT_ID').':'.env('EVEONLINE_CLIENT_SECRET') 
      ) 
     ], 
     'json' => [ 
      'grant_type' => 'refresh_token', 
      'refresh_token' => $refresh_token, 
     ]   
    ]); 
関連する問題