gpt4 book ai didi

android - 喜欢使用 YouTube 数据 API v3 在 YouTube 上使用访问 token 的视频吗?

转载 作者:行者123 更新时间:2023-11-30 03:22:32 26 4
gpt4 key购买 nike

我想喜欢 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;
}

提前致谢。

最佳答案

我建议您使用 Google API Java client libraryYouTube Service .

Examples hereAndroid sample project .

如果没有,您可以从 API explorer 生成示例请求.

关于android - 喜欢使用 YouTube 数据 API v3 在 YouTube 上使用访问 token 的视频吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18856551/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com