【发布时间】:2013-09-22 06:53:38
【问题描述】:
我想喜欢 YouTube 的视频。
我已使用 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。
我生成了这个 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