2016-04-14 26 views
0

テスト用のYouTubeアカウントを作成しました。チャンネルIDを使用してこのチャンネルにアップロードされたすべてのビデオを取得し、これらのビデオをすべて認証なしでユーザーに表示します。 YouTubeのAPIページ以下の場合:チャンネルIDを使用してチャンネルにアップロードされたすべてのvidoesを取得するためのYoutube API

https://developers.google.com/youtube/v3/sample_requests#playlists 

私は、チャネルIDとAPIキーを使用して、すべてのアップロードした動画をフェッチするunathenticated要求のために使用することができるAPIを発見しました。

BASE_URLがある
You can request information about information about a channel's public playlists without authentication. When you submit an unauthenticated request, you need to include the key argument that specifies the unique API key for the application making the request. For example, this request retrieves the playlists associated with the GoogleDevelopers channel. 

GET {base_URL}/playlists?part=snippet 
         &channelId=UC_x5XG1OV2P6uZZ5FSM9Ttw 
         &key={YOUR_API_KEY} 

https://www.googleapis.com/youtube/v3

これは私Developers consoleで応答を与えます。しかし、Http requestを発射すると、以下のエラーが発生します。

{ 
"error": { 
    "errors": [ 
    { 
    "domain": "usageLimits", 
    "reason": "keyInvalid", 
    "message": "Bad Request" 
    } 
    ], 
    "code": 400, 
    "message": "Bad Request" 
} 
} 

ここで何が間違っていますか?なぜ私は開発者コンソールで認証なしで応答を得ているのですか?直接HTTP要求が行われたときにエラーがスローされるのはなぜですか?解決

問題:

I was using OAuth key instead of API key. I created server key and used this key to send HTTP request and now getting the Json response. 

答えて

0

あなたはWebViewのを使用してフラグメントにユーチューブを埋め込むことができます。私はどこYOU_TUBE_DEMO_URL意志あなただけの1行

getSupportFragmentManager().beginTransaction() 
         .add(R.id.frag_root, UniversalWebViewFragment.newInstance(YOU_TUBE_DEMO_URL, false)).commit(); 

の助けを借りてあなたのアプリ上の任意のチャンネルを表示することができますGitHubの

https://github.com/hiteshsahu/Android-Universal-Web-Content-Loader/blob/master/src/com/serveroverload/universal_webloader/HomeActivity.java

上のソースをアップロードしたものWebViewの助けを借りてこれを達成していますAndroidDevelopers公式チャンネルにリダイレクトします。

さらに、これを実行するために、認証や外部jarを使用する必要はありません。

+0

私は私の問題を解決しました。私の編集された答えをチェック.. –

関連する問題