10

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

Fatal error: Uncaught OAuthException: (#803) Some of the aliases you requested do not exist: 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

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?

Chris Masterton
  • 2,197
  • 4
  • 24
  • 30

4 Answers4

26

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 integer in my mysql database, I changed this to treat it as a varchar, so now there's no issue

Daniel
  • 23,129
  • 12
  • 109
  • 154
  • 2
    Why didn't u just use a `BIGINT` instead of a VARCHAR? – Noam Feb 10 '14 at 14:11
  • 4
    a `BIGINT` would certainly cover the ID above. However, Facebook documentation note the user ID as being "numeric string", other IDs (albums, apps, comments) are documented as being "string", so I would use a string storage rather then a numerical storage. It may be that some IDs have 0 prefixes which would get ignored by using a numeric storage. https://developers.facebook.com/docs/graph-api/reference/user/ – Daniel Feb 10 '14 at 14:17
  • This claims an unsigned 64bit is enough, though not official docs. http://stackoverflow.com/questions/7138119/saving-facebook-id-as-int-or-varchar – Noam Feb 10 '14 at 14:40
1

This question Getting list of Facebook friends with latest API suggests

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

Community
  • 1
  • 1
0xAli
  • 1,059
  • 10
  • 22
  • I'm not even trying anything that complicated, just trying to post to a users stream. They have given us publish_stream and offline access. – Chris Masterton May 05 '11 at 23:46
0

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.

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.

function get_str($field) {
    $value = '';
    if(isset($_GET[$field])) $value = $_GET[$field];
    return $value;
}
Himanshu
  • 31,810
  • 31
  • 111
  • 133
anov
  • 1
  • 5
-3

Define APP ID as integer, not string!

elo
  • 615
  • 4
  • 11