Like video with access token on YouTube using YouTube Data API v3?(喜欢使用 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 上使用访问令牌的视频吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:喜欢使用 YouTube 数据 API v3 在 YouTube 上使用访问令牌的视频吗?


基础教程推荐
- “让"到底是怎么回事?关键字在 Swift 中的作用? 2022-01-01
- :hover 状态不会在 iOS 上结束 2022-01-01
- LocationClient 与 LocationManager 2022-01-01
- 如何使用 YouTube API V3? 2022-01-01
- Android ViewPager:在 ViewPager 中更新屏幕外但缓存的片段 2022-01-01
- 如何使 UINavigationBar 背景透明? 2022-01-01
- 在 iOS 上默认是 char 签名还是 unsigned? 2022-01-01
- Android文本颜色不会改变颜色 2022-01-01
- 固定小数的Android Money Input 2022-01-01
- 使用 Ryzen 处理器同时运行 WSL2 和 Android Studio 2022-01-01