Reputation: 10348
Using php-sdk I obtain pages in this way:
$array = $this->instance->api(
'/' . $fb_user . '/accounts', 'GET', array('access_token' => $access_token)
);
Now var_dump($array['data']);
gives me:
array (
0 =>
array (
'name' => 'my name 1',
'access_token' => '***',
'category' => 'Electronics',
'id' => '***',
),
1 =>
array (
'name' => 'my name 2',
'access_token' => '***',
'category' => 'Application',
'id' => '***',
)
Only the first item is a page, the second is an app. Any way to distinguish them or improve this snippet?
EDIT: Using the category
field seems a too weak procedure.
Upvotes: 1
Views: 195
Reputation: 901
If you don't want to rely on "category", you need to fetch informations from these ids.
Run a query for:
https://graph.facebook.com/[page_or_app_id]
Among other things, there will be field:
{
[...]
"type": "application"
]
or:
{
[...]
"type": "page"
]
To avoid long responses, you may consider Batch Requests as described:
Upvotes: 2
Reputation: 31870
Give that the category says "Application", I'd use the category property to filter with.
Alternatively, if as you say using category is too weak for you. You can use strong FQL. SELECT display_name FROM application WHERE app_id='{the id from your me/accounts}'
and see if you get back an object or not.
Upvotes: 1