我在哪里可以找到官方的图谱API错误代码列表?
我已经使用Graph API半年了,在过去的6个月里,错误代码的格式已经改变了两次!
我第一次看到错误代码,它看起来像:
{
"error": {
"message": "Error invalidating access token: The session has been invalidated because the user has changed the password.",
"type": "OAuthException",
}
}
Run Code Online (Sandbox Code Playgroud)
这真的很奇怪,错误消息没有提供任何错误代码!
然后几个月后,引入了"预期的"错误代码.
{
"error": {
"message": "Error invalidating access token: The session has been invalidated because the user has changed the password.",
"type": "OAuthException",
"code": 190,
}
}
Run Code Online (Sandbox Code Playgroud)
但遗憾的是,你仍然无法通过检查"代码"来区分错误是什么,因为许多具有相同"类型"的错误具有相同的"代码".
刚才,我发现错误信息包含新字段:
{
"error": {
"message": "Error invalidating access token: The session has been invalidated because the user has changed the password.",
"type": "OAuthException", …Run Code Online (Sandbox Code Playgroud) 我已经阅读了很多关于从Facebook获取信息的教程,但到目前为止我都失败了.我只是想从Facebook获取用户名和个人资料图片.
- (IBAction)login:(id)sender {
[FBSession openActiveSessionWithReadPermissions:@[@"email",@"user_location",@"user_birthday",@"user_hometown"]
allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
switch (state) {
case FBSessionStateOpen:
[[FBRequest requestForMe] startWithCompletionHandler:^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
if (error) {
NSLog(@"error:%@",error);
} else {
// retrive user's details at here as shown below
NSLog(@"FB user first name:%@",user.first_name);
NSLog(@"FB user last name:%@",user.last_name);
NSLog(@"FB user birthday:%@",user.birthday);
NSLog(@"FB user location:%@",user.location);
NSLog(@"FB user username:%@",user.username);
NSLog(@"FB user gender:%@",[user objectForKey:@"gender"]);
NSLog(@"email id:%@",[user objectForKey:@"email"]);
NSLog(@"location:%@", [NSString stringWithFormat:@"Location: %@\n\n",
user.location[@"name"]]);
}
}];
break;
case FBSessionStateClosed:
case FBSessionStateClosedLoginFailed: …Run Code Online (Sandbox Code Playgroud) 我过去很容易在API 1.0中获取用户的用户名,使用/me并获取username响应对象的属性.
现在我在使用API 2.0时出现此错误:
对于版本v2.0及更高版本,不推荐使用"(#12)用户名"
我发现到目前为止唯一的方法是使用FQL,但现在它似乎已被弃用.
有人知道解决这个问题吗?谢谢!
我最近在发布到应用程序用户的facebook新闻源流时遇到此错误,我确实拥有访问令牌的离线访问权限,并且之前工作正常.30-40%的用户会遇到此错误.
"Error validating access token: Session does not match current stored session.
This may be because the user changed the password since the time the session
was created or may be due to a system error."
Run Code Online (Sandbox Code Playgroud) 好的,首先让我告诉你我没有问题获取用户的相册并循环输出以显示我想要的所有尺寸的照片.
但是,如果我想打电话给照片:
<img src="https://graph.facebook.com/<?=$this->session->page->photo_id?>/picture?access_token=<?=$this->session->member->facebook_access_token?>" />
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚如何告诉它我希望它显示的大小.
在这个来自Facebook的示例代码中,您将看到乳清检索相册,阵列中的每张照片都会返回此示例数组中的不同大小.我可以从中保存缩略图网址,但我不想存储它,只需在需要时检索.
{
"id": "10150146071831729",
"from": {
"name": "Facebook",
"category": "Product/service",
"id": "20531316728"
},
"picture": "http://photos-g.ak.fbcdn.net/hphotos-ak-ash1/168119_10150146071831729_20531316728_7844072_5116892_s.jpg",
"source": "http://a7.sphotos.ak.fbcdn.net/hphotos-ak-ash1/168119_10150146071831729_20531316728_7844072_5116892_n.jpg",
"height": 483,
"width": 720,
"images": [
{
"height": 483,
"width": 720,
"source": "http://a7.sphotos.ak.fbcdn.net/hphotos-ak-ash1/168119_10150146071831729_20531316728_7844072_5116892_n.jpg"
},
{
"height": 120,
"width": 180,
"source": "http://photos-g.ak.fbcdn.net/hphotos-ak-ash1/168119_10150146071831729_20531316728_7844072_5116892_a.jpg"
},
{
"height": 87,
"width": 130,
"source": "http://photos-g.ak.fbcdn.net/hphotos-ak-ash1/168119_10150146071831729_20531316728_7844072_5116892_s.jpg"
},
{
"height": 50,
"width": 75,
"source": "http://photos-g.ak.fbcdn.net/hphotos-ak-ash1/168119_10150146071831729_20531316728_7844072_5116892_t.jpg"
}
],
....... continued...
}
Run Code Online (Sandbox Code Playgroud)
必须有一种方法来检索这些不同的大小.
谢谢.
Facebook在这里有一些很好看的Open Graph请求示例:
https://developers.facebook.com/docs/reference/api/examples/
问题是因为我没有访问令牌,所以大多数示例都会返回
{
"error": {
"message": "An active access token must be used to query information about the current user.",
"type": "OAuthException",
"code": 2500
}
}
Run Code Online (Sandbox Code Playgroud)
我理解访问令牌,但是如何获取令牌以便我可以试验这些示例请求?
我正在寻找一种使用新的Open Graph API执行FQL(facebook查询语言)查询的方法.
有谁知道我怎么做到这一点?
通过以下优秀示例找到答案:http: //code.google.com/p/facebook-cpp-graph-api/
我一直试图弄清楚如何做到这一点,并认为这是不可能的,然后找到这个网站:(由于死链接删除)
你可以在那里搜索城市,我不知道他们是怎么做到的?正如我所见,普通图API不允许按位置搜索事件.任何建议/提示/信息都会很棒!
我想知道是否有可能以编程方式发现特定API的所有端点.
例如,如果我使用浏览器或卷曲获取此URL:https: //api.twitter.com/1.1/
我可能会得到类似这样的JSON响应:
{"TwitterAPI":{
"version" : 1.1,
"GET" : {
"search/" : ["users", "trending"],
"users/" : ["id", "handle"]
}
}
Run Code Online (Sandbox Code Playgroud)
当然,Twitter可以选择发布或不发布此格式.所以作为一个附带问题,是否有任何Java或Javascript库可以自动映射和发布您在控制器中创建的API路由?
我正在尝试新的Facebook Messenger平台,并遇到了一些问题.
当用户第一次与我的Bot聊天时,我想使用它sender.id在我的数据库中查找用户并验证他们是否是客户,并提供更加量身定制的用户体验.
用户使用Facebook登录注册我的服务,但不幸的是,由于ID仅限于应用程序范围,我的App的Facebook ID和我的Bot的Facebook ID不同.
是否有任何方式关联2个ID以允许我在我的数据库中找到用户?
更新(2016年4月2日): 我们通过询问用户首次通过信使联系点击链接登录他们的帐户来解决这个问题,这样我们就可以将他们的messenger_id与他们在我们数据库中的帐户相关联.
如果facebook在ids_for_business端点中包含PAGE_SCOPED ID,那将是非常棒的.
更新:(2016年6月1日): Facebook的最新更新包括一个新的"帐户链接"功能,似乎可以解决这个问题.请参阅https://developers.facebook.com/docs/messenger-platform/account-linking
facebook facebook-graph-api facebook-login facebook-messenger