我要像YouTube的视频。
我已经获得的的auth_token 使用的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-视频:速度说明如何评价一个视频 但我不知道我怎么可以用我的CLIENT_ID,REDIRECT_URI,从谷歌API控制台生成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
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?
与谷歌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;
}
在此先感谢。
Thanks in advance.
我会建议你使用的谷歌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.