du4822 2013-07-17 18:47
浏览 36

Facebook FQL - 需要用户访问令牌才能请求此资源

I've been having a problem with a specific FQL call for a few days now, hoping someone can point me in the right direction, and yes, correct permissions are being asked for.

Using the PHP SDK, making the following FQL multiquery works

$user_fql = urlencode("SELECT uid, first_name, middle_name, last_name, name, birthday_date, hometown_location, current_location, education, religion, political, interests, work FROM user WHERE uid = me()");
$friend_count_fql = urlencode("SELECT friend_count FROM user WHERE uid = me()");
$multiquery = json_encode(array("user" => $user_fql, "friend_count" => $friend_count_fql));
$user = $facebook->api("/fql?q=".$multiquery."&access_token=".$access_token."&format=json-strings");

However when making this FQL call

$friends_fql = urlencode("SELECT uid, first_name, middle_name, last_name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) LIMIT 10");
$friends = $facebook->api("/fql?q=".$friends_fql."&access_token=".$access_token."&format=json-strings");

The following error is thrown

{"error":{"message":"A user access token is required to request this resource.","type":"OAuthException","code":102}}

And the permissions we are asking for

create_note email, friends_birthday, friends_education_history, friends_groups 
friends_hometown, friends_interests, friends_likes, friends_location, 
friends_relationships, friends_religion_politics, friends_work_history, photo_upload, 
publish_actions, publish_stream, read_stream share_item status_update user_birthday 
user_education_history, user_hometown, user_likes user_location, user_religion_politics, 
user_work_history, video_upload

I can't figure why getting user's friends info is throwing an OAuthException since this was working locally before pushing it to a remote server and the user access token I'm testing with is valid for the app and hasn't expired. Any suggestions would be much appreciated!

  • 写回答

1条回答 默认 最新

  • duanbi2003 2013-07-18 20:42
    关注

    I would suggest using your uid instead of me() because I'm guessing that when you left your local environment facebook isn't grabbing the me() correctly.

    I just tried your call on my graph api explorer and didn't get any problems and since you're not getting a permissions error it must be facebook doesn't know who "me()" is.

    Double check that you are logged onto facebook in the environment your working on/ try running the call with your uid.

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?