【问题标题】:Like video with access token on YouTube using YouTube Data API v3?喜欢使用 YouTube 数据 API v3 在 YouTube 上使用访问令牌的视频吗?
【发布时间】:2013-09-22 06:53:38
【问题描述】:

我想喜欢 YouTube 的视频。 我已使用 AccountManager

获得 AUTH_TOKEN

使用下面的

am.getAuthToken(mAccount, AUTH_TOKEN_TYPE, null, this, new AccountManagerCallback<Bundle>()
    {
    public void run(AccountManagerFuture<Bundle> future)
    {
        try
        {
            if(future != null && future.getResult() != null)
            {                           if(future.getResult().containsKey(AccountManager.KEY_AUTHTOKEN))
                {                   
                AUTH_TOKEN = future.getResult().getString(AccountManager.KEY_AUTHTOKEN);
                          }
            }
        }
        catch(OperationCanceledException e)
        {               }
        catch(AuthenticatorException e)
        {               }
        catch(IOException e)
        {               }
        catch(Exception e)
        {               }
        }
        }, null);

现在我想为视频点赞(评分) developers.google.com- Videos: rate 解释如何为视频评分
但我不知道如何使用从 Google API 控制台生成的 CLIENT_ID、REDIRECT_URI、CLIENT_SECRET。

我生成了这个 uri

String uri ="https://www.googleapis.com/youtube/v3/videos/rate?id="+ TEST_VIDEO_ID + "&rating=like&mine=true&access_token="+AUTH_TOKEN + "&key=" + DEVELOPER_KEY;

这个 uri 是否错误,我如何将https://www.googleapis.com/youtube/v3/videos/rate? 与 Google API 控制台的常量一起使用

我正在使用以下方法使用此 uri 字符串,该方法未响应 developer.google.com 上指定的正确结果 我正在使用这种方法从 youtube 获取响应(如视频列表、播放列表等),但我认为这在这种情况下不起作用或不起作用

请帮忙!!!!

private JSONObject getResponse(String apiUrl)
    {
        try
        {
            HttpClient client = new DefaultHttpClient();
            HttpUriRequest request = new HttpGet(apiUrl);
            HttpResponse response = client.execute(request);
            String jsonString = StreamUtils.convertToString(response.getEntity().getContent());
            JSONObject mJson = new JSONObject(jsonString);
            return mJson;
        }
        catch(ClientProtocolException e)
        {}
        catch(Exception e)
        {}

        return null;
    }

提前致谢。

【问题讨论】:

  • 您是否找到任何使用 V3 对 Youtube 视频进行评分的解决方案

标签: android youtube-api accountmanager google-api-console youtube-data-api


【解决方案1】:

我建议你使用Google API Java client libraryYouTube Service

Examples hereAndroid sample project

如果不是,您可以从API explorer 生成示例请求。

【讨论】:

    【解决方案2】:

    在您的请求中,将 access_token 设置为授权标头。

    【讨论】:

      猜你喜欢
      • 2012-12-09
      • 2019-01-11
      • 2015-04-29
      • 1970-01-01
      • 2018-06-23
      • 2012-01-14
      • 1970-01-01
      • 2013-11-12
      相关资源
      最近更新 更多