LoginSignup
0
0

More than 5 years have passed since last update.

Yahoo在庫に関連するAPI・アクセストークン取得方法について

Posted at

Yahoo在庫に関連するAPI・アクセストークン取得方法について

在庫に関連するAPI(プロフェッショナル出店ストア向け)のアクセストークン取得のため、こちらのリンクを参照しました。
http: //developer.yahoo.co.jp/yconnect/server_app/explicit/token.html

コードを作成しましたが、 http://54.172.103.152/yahoo/YahooConnect/testYconnect.php
と出てしまいます。問題をご指摘頂ければ幸いです。作成したコードは下記の通りです(2つ)。

GetAuthorizationCode($state); //$Code_result = "k5bvfdyc"; // Token endpoint to request $client->RequestAccessToken($redirect_uri ,$Code_result); // Access token, get a refresh token $access_token = $client -> getAccessToken(); $refresh_token = $client -> GetRefreshToken(); } catch ( TokenException $e ) /*and */{ // Please issue the authorization code to log in again } ?>

$_GET ['code'] , 'code' => 'k5bvfdyc' , 'grant_type' =>'authorization_code', 'redirect_uri' => callback_url, ) ; // POST send $options = array ('http'=> array ( 'method'=>'POST', 'content'=> http_build_query ( $params ) , 'header'=>'Authorization: Basic '. base64_encode ( CONSUMER_KEY.':'.CONSUMER_SECRET ) , )) ; $res = file_get_contents ( TOKEN_URL, false , stream_context_create ( $options )) ; // Response get $token = json_decode ( $res , true ) ; if ( isset ( $token ['error'])) { echo'error'; exit ; } $access_token = $token ['access_token'] ; // -------------------------------------- // try to get the user information // -------------------------------------- $options = array ('http'=> array ( 'method'=>'GET', 'header'=>'Authorization: Bearer'. $access_token , )) ; $res = file_get_contents ( INFO_URL, false , stream_context_create ( $options )) ; echo "

". print_r ( json_decode ( $res , true ) , true ) ." ";

?>

よろしくお願いします。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0