Facebook PHP 抛出异常“(#803)您请求的某些别名不存在”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5892897/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 22:49:26  来源:igfitidea点击:

Facebook PHP throwing exception "(#803) Some of the aliases you requested do not exist"

phpfacebookfacebook-graph-api

提问by Chris Masterton

I have a valid and authenticated user, but when posting to their wall from our PHP web app it returns:

我有一个有效且经过身份验证的用户,但是当从我们的 PHP Web 应用程序发布到他们的墙上时,它返回:

Fatal error: Uncaught OAuthException: (#803) Some of the aliases you requested do not exist: xxxxxxxxxxxxx","name":"xxxxxxx

致命错误:未捕获的 OAuthException:(#803)您请求的某些别名不存在:xxxxxxxxxxxxx","name":"xxxxxxx

I have 24 other users that can post with no issues. And I can see the user exists by going to https://graph.facebook.com/xxxxxxxxxxxxx

我还有 24 个其他用户可以毫无问题地发帖。我可以通过访问https://graph.facebook.com/xxxxxxxxxxxxx看到用户存在

Here is the code:

这是代码:

    $fb_user_id = $row[0]; // loaded from DB
    $facebook_token = $row[1]; // loaded from DB

    $result = $facebook->api('/' . $fb_user_id. '/feed/',
                                'post',
                                array('access_token' => $facebook_token,
                                    'message' => $postMessage,
                                    'name' => 'Product name',
                                    'caption' => 'Accomplished!',
                                    'link' => 'http://www.xxxxxxx.com/',
                                    'description' => $postMessage,
                                    'picture' => 'http://www.xxxxxxx.com/images/productImage.png'));

Any ideas why the Facebook API thinks this user does not exist?

为什么 Facebook API 认为该用户不存在的任何想法?

回答by Daniel

I had this issue, later I realised I was saving the uid in my database as an integer, however, new facebook profiles have very long uids, such as : 100004409446248, this was not a value I could save as an integerin my mysql database, I changed this to treat it as a varchar, so now there's no issue

我有这个问题,后来我意识到我保存在我的数据库中的UID作为integer,然而,新的Facebook个人主页有很长的UID,如:100004409446248,这不是一个值,我可以保存为integer我的MySQL数据库,我改变this 将其视为 a varchar,所以现在没有问题

回答by 0xAli

This question Getting list of Facebook friends with latest APIsuggests

这个问题使用最新的 API 获取 Facebook 好友列表建议

$friends = $facebook->api('/me/friends');

$friends = $facebook->api('/me/friends');

回答by anov

I wrote two library routine for get integer querystrings. Similar to Dainel's experience when I use the intval()function, I get an invalid Facebook id cause produce that error.

我写了两个库例程来获取整数查询字符串。与我使用该intval()功能时 Dainel 的经历类似,我得到了一个无效的 Facebook id,导致产生该错误。

Code:

代码:

function get_int($field) {
    $value = 0;
    if(isset($_GET[$field])) $value = intval($_GET[$field]);
    return $value;
}

I use the get_str for facebook_id and problem was gone.

我将 get_str 用于 facebook_id 并且问题消失了。

function get_str($field) {
    $value = '';
    if(isset($_GET[$field])) $value = $_GET[$field];
    return $value;
}

回答by elo

Define APP ID as integer, not string!

将APP ID定义为整数,而不是字符串!