Facebook API V3 - Create Facebook Page for Test User - facebook

I have an application that uses Facebook login module.
I tried to get manage_page and publish_page permissions but Facebook is not giving these permission without review. So, I tried to create test user and gave him above permissions.
Then logged into Facebook with test user. Facebook is not letting test user to create facebook page.
I need to access user's pages but cannot do because I cannot create at the first place.

I got the access_token of the test user and called facebook api with following json. And then I can see my test user had created page when I login to facebook.
/me/accounts
{
"name": "Your Page Name",
"category": 2211,
"about": "Description",
"picture": "your_page_picture_url",
"cover_photo": {
"url": "your_page_cover_photo_url"
},
"classic": 0,
"city_id": 2505639
}

Related

Facebook Graph - Instagram Business ID: not always returned for the same page

I'm facing to a strange issue with Facebook Graph API: for a given Facebook Page, the API does not always retrieved the Instagram Business ID associated.
My client have his page "WonderfulClientPage" which he is owner and admin.
He invited me to be administrator of his page. So, both of our Facebook accounts have the MANAGE role.
When he trying to get his Instagram Business ID from the Graph API through our Facebook App, it does not working: the API replying without the ID. The API response:
{
"id": "100[...]966"
}
But, when I'm doing the same with my account, it's working fine:
{
"instagram_business_account": {
"id": "178[...]519"
},
"id": "100[...]966"
}
When tried to do it with another account, freshly invited as an administrator: it's working !
It seems it's mandatory to be a "recent" administrator of a page to retrieved the Instagram Business ID ... It's look liker weird.
The HTTP request:
GET https://graph.facebook.com/v11.0/100[...]966?access_token=EAAGqeRDgkT8BAF[...]WMc90asIcZD&fields=instagram_business_account
Data from Token Debug (https://developers.facebook.com/tools/debug/accesstoken/):
Type: User
Valid: True
Origin: Web
Scopes: email, read_insights, pages_show_list, ads_management, business_management, instagram_basic, instagram_manage_insights, instagram_content_publish, pages_read_engagement, pages_manage_posts, public_profile
Does someone had the same issue ? Is there something else I'm missing to explain that ?

Retrieving pages for a newly created admin user of a page returns empty

My applicaton uses this endpoint to retrieve a list of pages to which a user has access.
For my personal account, which is the admin of a page, it works fine:
https://graph.facebook.com/me/accounts?access_token=[accesstoken_for_my_personal_profile]
Results:
{
"data": [
{
"access_token": "<the access token>",
"category": "Record Label",
"name": "Page Name",
"id": "Page ID",
"perms": [
"ADMINISTER",
"EDIT_PROFILE",
"CREATE_CONTENT",
"MODERATE_CONTENT",
"CREATE_ADS",
"BASIC_ADMIN"
]
}
]
}
But when we create a totally new facebook profile (regular user, as per my personal one) - and get it verified using mobile phone / SMS based verification, it only ever returns blank here, despite being given page admin access to the same page and having requested an access token exactly the same way:
https://graph.facebook.com/me/accounts?access_token=[accesstoken_for_newly_created_profile]
{
"data": [
]
}
UPDATE
The access token permissions are also different.
So when calling https://graph.facebook.com/me/permissions?access_token=xxx, the bad user only has public_profile and installed as 'granted' - but the good user has all the requested permissions including 'manage_pages'.
The URL used to request the tokens in the first place is here:
https://www.facebook.com/dialog/oauth?client_id=[my_app_id]&redirect_uri=https://www.facebook.com/connect/login_success.html&scope=manage_pages,read_mailbox,read_stream,publish_actions,user_likes&response_type=token
This directs to a login page which logs in as the user for which we want a token.
Courtesy of #CBroe above:
The issue here was that since API v2.0 came in, requesting access tokens for users who do not have a role in the requesting app will not assign certain permissions (in our case 'manage_pages') unless the app has been reviewed.

I can post links in a page feed but not just a message

I'm trying to post to a facebook page (as the page and as the admin user with each one access token) with just a parameter 'message'.
I've the same error in php and in Graph API Explorer in both cases:
{
"error": {
"message": "(#1) An unknown error occurred",
"type": "OAuthException",
"code": 1,
"error_data": {
"kError": 1455002
}
}
}
The same post to the API adding a paremeter link or just link without message works fine.
The user has granted those permissions: create_note, email, manage_pages, photo_upload, publish_actions, publish_stream, share_item, status_update, user_friends, video_upload.
The app is in Sandbox Mode and the user is a test user, not a real one.
I'm able to write to user feed and to create custom actions for him.
I've verified both, the page access token and the user access token with Access Token Debugger.
I've already reviewed a lot of questions in stackoverflow, tutorials and blog posts.
What am I missing?
UPDATED: I can't either post a link in page with app access token.

How to check if a Facebook user liked an FB page from an external website

I have a web page which displays Facebook LIKE Box.. I need to check if a user liked my Facebook page or not and present contents to them accordingly.. doing Facebook authentication for this from my external web page is perfectly fine..
You need to use the Graph API with and check the User's likes. Here is an example.
https://graph.facebook.com/{USER_ID}/likes/{PAGE_ID}
If the user likes the page in question, it will return JSON looking like this if the user likes the page.
{
"data": [
{
"name": "bread&cup",
"category": "Restaurant/cafe",
"id": "157758372652",
"created_time": "2012-02-15T15:36:38+0000"
}
],
"paging": {
"next": "https://graph.facebook.com/me/likes/157758372652?format=json&limit=5000&offset=5000&__after_id=157758372652"
}
}
And like this if the user doesn't like the page:
{
"data": [
]
}
Here's the documentation on User likes:
https://developers.facebook.com/docs/reference/api/user/#likes
There is another way that doesn't require permissions in advance, but doesn't work perfectly on its own - ideally use it in conjunction with a log in system.
1) Subscribe to the Facebook.edge event (this means 'do something when like is clicked')
2) Create a cookie when user likes the page
Then, when a user returns, you can run the following code:
1) If user logged in, check FB API and check properly
2) If user not logged in, check cookie
This means the user who liked your site will get full access to whatever it is you're giving to fans only from that computer until they clear their cookies - at which point they will have to sign in to your site and provide like permissions.
Here's facebook edge event - Facebook edge.create
Here's create cookie stuff - How do I set/unset cookie with jQuery?
Dave

How do I add a custom tab to a Facebook application profile page programmatically?

I am able to add custom tabs to my Facebook pages, by using the Graph API,
[https://graph.facebook.com/page_id/tabs] and using HTTP POST.
However, I am unable to add custom tabs to my Facebook application's profile page. Infact the API, [https://graph.facebook.com/page_id/tabs], with HTTP GET also fails.
(I mean, I cannot even get the tabs for my Facebook application's profile page with the API.)
What am I doing wrong?
Here I am listing what I am trying to do:
I get an access_token (say a1) for a user (admin_user) using the manage_pages permission.
With this access_token (a1), I use Graph API, >[https://graph.facebook.com/me/accounts] and get back a list of pages (pages and application profile pages):
{
"data": [
{
"name": "Bg",
"access_token": "***",
"category": "Industrials",
"id": "*****"
},
{
"name": "Testapp2Pip",
"access_token": "*******",
"category": "Application",
"id": "***"
},
Now I use the Graph API, [https://graph.facebook.com/page_id/tabs]
Case 1. If I use the page_id for the background page (which is a normal page) and the corresponding access_token, I get back the tabs for the page.
Case 2. If I use the page_id for the Testapp2Pip page (which is an application profile page) and the corresponding access_token, I get an error:
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException"
}
}
What am I doing wrong here? How do I get the tabs for an application profile page? Also, I would actually want to add custom tabs to the application profile page by using Graph API.
Have you added the app to the app profile page, and/or double checked that it is added as an app? It seems odd, but you can add/remove the app from the apps own page. I'm guessing if the app isn't added, then it wouldn't have access to the page information.
An alternative option is to get an access token for the application, not the current user. This page has instructions for getting an access token for the app, instead of the user. Scroll down to the "App Login" section.
http://developers.facebook.com/docs/authentication/
Okay, so this is a bug. I have filed the bug with Facebook.