Facebook API: determine if a Facebook page is being published or not being published

What is a reliable way to verify the publication or non-publication of a Facebook page using the graphical API? I am currently doing this:

http://graph.facebook.com/ {page_id}

and check if the return value is false. If it is false, I conclude that it is not published, and if it returns a graph object, then conclude that it is published. But now I notice that many published pages return false from the above query.

Here is an example:

This page is published: http://www.facebook.com/AjiRestaurant

but these requests return false: http://graph.facebook.com/104433516257517 (using the page id) http://graph.facebook.com/AjiRestaurant (using the page username)

What is the best way to check if a page is being published?

+7
source share
5 answers

Drop it under the FQL query at http://developers.facebook.com/tools/explorer

SELECT page_id, name, username, is_published FROM page WHERE page_id IN (SELECT page_id FROM page_admin WHERE uid = me()) AND is_published="" ORDER BY fan_count DESC 

This will select all the pages in your account and see if they are published, returning all the unpublished pages in the list.

+3
source

It turns out there is no known way to check if the Page is published / not published. The API column http://graph.facebook.com/ {page_id} will return false if one of the following conditions is true:

  • Page not published
  • The page has country restrictions.
  • The page has age restrictions.

If and only if none of the above settings is applied, http://graph.facebook.com/ {page_id} will return an object graph.

Note. I assume that the access token with the manage_pages permission is not used for the above API calls. With the correct access token, https://graph.facebook.com/ {page_id} will return the object graph, regardless of whether the page has restrictions or not.

+2
source

You can use the following, but it works when you have permission to manage pages on the page http://graph.facebook.com/{page_id}/settings

try this code with manage_pages permission

 FB.api('/me/accounts', function (resp) { //var txtpageid = if (txtpageid != '') { FBactualID = ''; for (var i = 0, l = resp.data.length; i < l; i++) { var page = resp.data[i]; if (page.id == txtpageid) { FBactualID = txtpageid; varFBResponseFlag = true; //alert('inside the page id validation'); } } } getCheckedValue(FBactualID); }); 
0
source

Retrieve the page using the Graph API (using cURL as a system call, HTTPClient with Rails or $.getJSON() using jQuery, for example) using http://graph.facebook.com/PAGE_ID . Unpublished pages return false , and published pages return an array of JSON information.

This does not require access or permission tokens.

Using cURL (command line)

 $ curl http://graph.facebook.com/UNPUBLISHED_PAGE_ID false $ curl http://graph.facebook.com/PAGE_ID {"id":"1234","name":"Test Page","picture":.... 

Using HTTPClient (with Rails)

 HTTPClient.get("http://graph.facebook.com/UNPUBLISHED_PAGE_ID").body # false HTTPClient.get("http://graph.facebook.com/PAGE_ID").body # "{\"id\":\"1234\",\"name\":\"Test Page\",\"picture\".... 

Using $ .getJSON () (jQuery)

 $.getJSON("http://graph.facebook.com/UNPUBLISHED_PAGE_ID", function (data) { console.log(data); // false } $.getJSON("http://graph.facebook.com/PAGE_ID", function (data) { console.log(data); // JSON Object with page info } 
0
source

You can only see the page if you use access_token , which can see the page in the request.

You will always see only the pages that you see with the access_token user on facebook.

Using my own access_token in the above examples, for example, still gives false for AjiRestaurant, but I will get the information for KeystoneLight as accurately as possible, since my account meets the restrictions.

0
source

All Articles