How to check Facebook app id

I need to check if the given Facebook app ID is valid. In addition, I need to check which domain and site settings are set for this application identifier. It doesn’t matter if it is done through PHP or Javascript.

I checked everywhere, but could not find any information about this. Any ideas?

+4
source share
3 answers

You can verify the identifier by selecting http://graph.facebook.com/<APP_ID> and see if it loads what you expect. For information about the application, try using admin.getAppProperties using the properties from this list .

+9
source

Use the Graph API. Just ask:

 https://graph.facebook.com/<appid> 

It should return you a JSON object that looks like this:

 { id: "<appid>", name: "<appname>", category: "<app category>", subcategory: "<app subcategory>", link: "<applink>", type: "application", } 

So, to check if the specified app_id is really the application identifier, find the type property and check if it speaks the application. If the identifier is not found at all, it will simply return false.

Additional information: https://developers.facebook.com/docs/reference/api/application/

For instance:

 <?php $app_id = 246554168145; $object = json_decode(file_get_contents('https://graph.facebook.com/'.$app_id)); // the object is supposed to have a type property (according to the FB docs) // but doesn't, so checking on the link as well. If that gets fixed // then check on isset($object->type) && $object->type == 'application' if ($object && isset($object->link) && strstr($object->link, 'http://www.facebook.com/apps/application.php')) { print "The name of this app is: {$object->name}"; } else { throw new InvalidArgumentException('This is not the id of an application'); } ?> 
+4
source

Use the Graph API:

 $fb = new Facebook\Facebook(/* . . . */); // Send the request to Graph try { $response = $fb->get('/me'); } catch(Facebook\Exceptions\FacebookResponseException $e) { // When Graph returns an error echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch(Facebook\Exceptions\FacebookSDKException $e) { // When validation fails or other local issues echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; } var_dump($response); // class Facebook\FacebookResponse . . . 

More info: FacebookResponse for SDK for PHP for PHP

0
source

All Articles