6

Android で新しい Youtube Data API を使用して、特定の ID からビデオ タイトルを取得しようとしています。

https://www.googleapis.com/youtube/v3/videos?id=6DbS1VB8HGo&part=player&key=XXX

ただし、ログインが必要で、エラー コード 401 という応答が返されます。

認証トークンと関係があると推測していますが、プレイリストの更新や削除などのアカウント固有の操作を実行していないため、なぜこれが必要なのかわかりません。私が欲しいのは、タイトルと、おそらくビューの数だけです。

以下は私が使用しているコードです。

public class NetTask extends AsyncTask<String, Void, String>{
    @Override
    protected String doInBackground(String... params) {
        HttpClient httpClient = new DefaultHttpClient();
        //param[0]= "https://www.googleapis.com/youtube/v3/videos?id=6DbS1VB8HGo&part=player&key=xxyy"
        HttpPost httpPost = new HttpPost(params[0]);
        HttpResponse response;

        try {
            response = httpClient.execute(httpPost);
            String responseString = EntityUtils.toString(response.getEntity());
            JSONObject responseJSON = new JSONObject(responseString);
            responseJSON.toString();

        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return null;
    }
}
4

1 に答える 1

0

API ドキュメントには次のように記載されています。

前提条件

  1. API リクエストを送信できるように、アプリケーションを Google に登録します。
于 2013-03-31T16:27:28.860 に答える