大学のプロジェクトで YouTube API を使用していますが、エラーが発生し続けます。ここでは、ログインするために認証ページに送信します。アクセスが許可されると、$_GET['code'] 文字列が返されます。次に、これを他のデータと一緒に送信すると、JSON オブジェクトが返されます。代わりに私はただ得ています
警告: file_get_contents(https://accounts.google.com/o/oauth2/token) [function.file-get-contents]: ストリームを開くことができませんでした: HTTP リクエストが失敗しました! http://www.example.net/callback.phpの 27 行目の HTTP/1.0 400 Bad Request
セキュリティのためだけにドメインを example.net に置き換えました
urlencode($_GET['コード']), 'client_id' => urlencode('111522767640.apps.googleusercontent.com '), 'client_secret' => urlencode('secret'), 'redirect_uri' => urlencode('http://example.net/callback.php'), 'grant_type' => urlencode('authorization_code') ) ); $params = array('http' => 配列( 'メソッド' => 'POST /o/oauth2/token HTTP/1.1', 'header' => 'ホスト: accounts.google.com\r\n'. 'コンテンツタイプ: application/x-www-form-urlencoded', 'コンテンツ' => $postdata ) ); $context = stream_context_create($params); $result = file_get_contents('https://accounts.google.com/o/oauth2/token', false,$context); var_dump($_SESSION); var_dump($結果); } else //コードが設定されていない場合、ユーザーは間違ってここに来たか、このプログラムへのアクセスを拒否したに違いありません { //header( '場所: www.example.net/error.php' ) ; } ?>