对于高中项目,我需要在我自己的 Android 应用程序内的 Facebook 页面上获取已上传视频的列表。
Facebook SDK 为此建议使用以下代码:
/* make the API call */
new Request(
session,
"/{page-id}/videos/uploaded",
null,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
/* handle the result */
}
}
).executeAsync();
我已经在请求中插入了我的页面的 ID。
问题是我需要提供一个访问 token 。使用 Graph Api Explorer,我可以浏览在他们这边提供我的访问 token 的查询的输出。如何在 Java 代码中提供访问 token ?
我得到的回应是这样的:
{Response: responseCode: 400, graphObject: null, error: {HttpStatus: 400, errorCode: 104, errorType: OAuthException, errorMessage: An access token is required to request this resource.}, isFromCache:false}
你能帮我解决如何为请求提供访问 token 吗
最佳答案
AccesToken 是通过 Facebook 登录服务获取的,当用户登录时,Facebook 会生成一个。你应该看看
https://github.com/sromku/android-simple-facebook
它是一个简化常见 Facebook API 任务(例如登录用户)的库。
关于java - 使用 Facebook Graph API 在 Android 应用中获取视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27819673/