Sylvain
Sylvain

Reputation: 3100

Get real Facebook userID from an app scoped

I'm using PHP Facebook SDK to get friends from an authenticated user :

GET /v2.2/<userID>/taggable_friends

And I get an array with elements like this :

object(stdClass)[4691]
  public 'id' => string 'AaJXJQ2G...VAnlcRjdLTsA' (length=110)
  public 'name' => string '...' (length=13)
  public 'picture' => 
    object(stdClass)[4690]
      public 'data' => 
        object(stdClass)[4689]
          public 'is_silhouette' => boolean false
          public 'url' => string 'https://scontent.xx.fbcdn.net/hprofile-xta1/....jpg?' (length=162)

Now I'd like to send a notification to some friends, but the id above is an "app scoped id", so if I call the notification API with this call :

POST /v2.2/<friend_app_scoped_ID>/notifications?access_token=<my_app_access_token>&href=<some_link>&template=<text>

I get this error :

(#803) Some of the aliases you requested do not exist: <friend_app_scoped_ID>

I think app scoped IDs are related to my app and I have to get real userID before sending my notification request.

Anyone knows how I can do this?

Thanks :)

Upvotes: 1

Views: 115

Answers (1)

Tomasz Struczyński
Tomasz Struczyński

Reputation: 3303

Facebook explicitly disallows the use of 'real' user ID and moved to app-scoped ones in FB API V2+.

Also, you can not send a notification to a person, who is not using your application. This is by default to disallow spam. You can - as name of this edge imples - TAG these people in stories on user feed. But only on the feed of the user using your app. They will receive notification, that someone tagged them in a post. But that is it.

and of course, all of these requires additional permissions, which will have to be reviewed by Facebook (I'm not sure, if you are familiar with a review process, but in short - they will manually check your application for compliance with their guidelines and disallow it, if it violates them).

Here's some article I have found describing usage of taggable friends API, with examples:

https://www.webniraj.com/2014/06/12/facebook-api-getting-friends-using-graph-api-2-0-and-php-sdk-4-0-x/

Upvotes: 2

Related Questions