喜欢使用 YouTube 数据 API v3 在 YouTube 上使用访问令牌的视频吗? [英] Like video with access token on YouTube using YouTube Data API v3?

查看:29
本文介绍了喜欢使用 YouTube 数据 API v3 在 YouTube 上使用访问令牌的视频吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to like video of YouTube. I have acquired AUTH_TOKEN using AccountManager

使用下面的

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.

Now i want to like(Rate) the video developers.google.com- Videos: rate explains how to rate a video
but i am unaware that how can i use my CLIENT_ID, REDIRECT_URI, CLIENT_SECRET generated from Google APIs Console.

我生成了这个 uri

I generated this 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 控制台的常量一起使用

Is this uri wrong how can i use https://www.googleapis.com/youtube/v3/videos/rate? with Google API console's Constants

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

I am using this uri string using the following method which is not responding right result as specified on developer.google.com I was using this method to get the response(like list of video, playlist etc) from youtube but i think this will not work or working in this case

请帮忙!!!!

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;
    }

提前致谢.

推荐答案

我建议你使用 Google API Java 客户端库YouTube 服务.

I would suggest you to use Google API Java client library and YouTube Service.

此处的示例Android 示例项目.

如果不是,您可以从 API 生成示例请求探险家.

If not you can generate sample requests from API explorer.

这篇关于喜欢使用 YouTube 数据 API v3 在 YouTube 上使用访问令牌的视频吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆