Lacking permissions on a facebook API post - facebook

I'm trying to publish on a page throught FB API (with curl), I give this commande with post method to curl : https://graph.facebook.com/my_Page_Id/feed?message=Helloworld!&access_token=MY_PAGE_TOKEN
I get the following error code :
[message] => (#200) If posting to a group, requires app being installed in the group, and \
either publish_to_groups permission with user token, or both pages_read_engagement \
and pages_manage_posts permission with page token; If posting to a page, \
requires both pages_read_engagement and pages_manage_posts as an admin with \
sufficient administrative permission
[type] => OAuthException
[code] => 200
[fbtrace_id] => probably not necessary
)
If I entry this URL into my browser, i get an empty JSon string just like following. But the post isn't sent too.
{
"data": [
]
}
My app is not reviewed, but it still in dev mode. So if i understand the doc well, it's supposed to don't require these permissions...

My app is not reviewed, but it still in dev mode. So if i understand the doc well, it's supposed to don't require these permissions...
No, you did not understand that correctly.
This API call still needs the necessary permissions to be granted by the user (a page admin). This has nothing to do with dev vs live mode.
To be able to ask users for those permissions, when in live mode, you will need to submit your app for review and get it approved though.
And as long as you are in dev mode, any such posts you made via the API, will only be visible to people with a role in your app, they will be hidden from everyone else.

Related

Facebook Graph API returns 200 status code when try to create a post for account

I created a Facebook account and I want to create a post with Facebook graph API by creating an http request from a C# server.
I created an app with Facebook developer:
I tried to create a post with Facebook's Graph API Explorer as explained in
https://developers.facebook.com/docs/pages/publishing/
I generated a token with pages_show_list and pages_read_engagement permissions. The app ID is the result GET request for "https://graph.facebook.com/v11.0" which returned an object with id property.
The POST request URL is: "https://graph.facebook.com/v11.0/{appId}/feed?message=hi&access_token={accessToken}"
I don't understand why I'm getting 200 status code and how can I fix it.
The error is:
(#200) If posting to a group, requires app being installed in the group, and \
either publish_to_groups permission with user token, or both pages_read_engagement \
and pages_manage_posts permission with page token; If posting to a page, \
requires both pages_read_engagement and pages_manage_posts as an admin with \
sufficient administrative permission",
As you can read in the docs, you need the following:
The pages_manage_posts permission
The pages_read_engagement permission
A Page access token requested by a person who is able to perform the CREATE_CONTENT task on the Page that is being queried
You are missing number one and number three, as far as I can see in your screenshot.
Btw, you can just use "/me/feed" instead, the ID is not neccessary as the Token includes it.

How do i use Facebook API to post only on my page?

As i understand, i need to validate my person, wait for my app review etc.
But what if i just need to post only on my page and nowhere else? Someone told me that i just have to be an app and page administrator and i even can leave app in dev mode but it didn't work for me. In all cases i just recieve
If posting to a group, requires app being installed in the group, and either publish_to_groups permission with user token, or both manage_pages and publish_pages permission with page token; If posting to a page, requires both manage_pages and publish_pages as an admin with sufficient administrative permission
Is it any way to skip all these checks and use API for posting? If not, can you tell me some free services i can use to reach this with? Much thanks for answers.
If you are posting to a page (any page) you need a token with manage_pages and publish_page.
You can generate a test token using the explorer: https://developers.facebook.com/tools/explorer/ - but this token is short lived (1h)
Using the short term token in the explorer, you can get a list of your pages (endpoint: /me/accounts) that you manage and that list will contain a page_token for each page you manage.
With that page_token you can post to the page.
You can put the page_token into the Access token debugger to see it's permissions.
https://developers.facebook.com/tools/debug/accesstoken/
You need approvals if you are putting the app live and allowing non-developers access to it.

Not able to post to Facebook using custom-ui project of socialauth-android project

I am not able to post Facebook using the custom-ui project of socialauth-android.
Here is the error log.
10-31 13:18:05.124: D/SocialAuthError(21880): org.brickred.socialauth.exception.SocialAuthException: org.brickred.socialauth.exception.SocialAuthException: Status not updated. Return Status code :403
10-31 13:18:05.124: W/System.err(21880): org.brickred.socialauth.android.SocialAuthError: Message Not Posted
10-31 13:18:05.124: W/System.err(21880): at org.brickred.socialauth.android.SocialAuthAdapter$6.run(SocialAuthAdapter.java:868)
10-31 13:18:05.124: W/System.err(21880): at java.lang.Thread.run(Thread.java:818)
I am not able to find the issue. I am using the same API keys got from the Github source.
You are getting 403 Authentication Error that clearly means that your app is presently not authorized to publish on Facebook profile of the user.
There is some problem the way you are trying to use Facebook APIs. I would suggest you to the latest Facebook SDK for Android as some of the older methods may be deprecated. Let me tell you the approach for doing this right way. (I recently implemented latest Facebook SDK)
You need a permission
There are some specific permissions that you require to do some specific operations with Facebook SDK. For example, You need publish_actions permission if you want your app to post status on user's profile.
Check Out It says,
For example, the publish_actions permission lets you post to a person's Facebook Timeline.
How to get Permissions
You need to show the user a login button which will ask him to do login with his facebook account and notifying the user what your app may do with his Facebook profile. It will show the permissions. In your case you need to add a login button with publish_actions permission. Once the user accepts it, your app becomes authorized to post status.
Complete Tutorial is here for doing the login process of Facebook with permissions.
You will need to do the following,
LoginButton authButton = (LoginButton) view.findViewById(R.id.authButton);
authButton.setFragment(this);
authButton.setReadPermissions(Arrays.asList("user_likes", "user_status", "publish_actions"));
return view;
So you can see we are asking the user to give you the publish_actions permission. It is not mandatory to include user_likes or user_status permissions. You can remove them if you don't need them.
Next what after login
After the user logs in, you get an authentication token in your session with Facebook. So now you can use that to publish on user's profile.
How to post
Now there are many ways to publish posts or status on Facebook. The first one I would like to discuss is using the Graph API
Here is somewhat code, you can use to publish to facebook.
Session session = Session.getActiveSession();
new Request(
session,
"/me/feed",
null,
HttpMethod.POST,
new Request.Callback() {
public void onCompleted(Response response) {
}
}
).executeAsync();
NOTE
You do also need to create developer account with facebook and add your app to its dashboard, generate an app_id and mention the same in your AndroidManifest.xml file.

How to post to my own timeline/page without requesting publish_actions and manage_pages permissions?

I have a blog website and I have a Facebook page where I would like to share updates from my blog. I also would like to share those updates to my personal profile/timeline. I made an application and requested the publish_actions and manage_pages permissions.
It got rejected with the following comment:
You do not need to request these permissions because your blog or CMS
is integrated with an app that you admin. As an App admin, you can
already access these permissions and post to your Timeline or a page
you admin. You can provide access to additional users by adding them
as developers of your App.”
Yes, I am an admin on website, app and Facebook profile/page.
But, can anyone tell me what does it mean?
I read documentation several times. It's pretty clear that I can post even to my own only with access_token. I can get access token if I ask for authorization.
If a request authorization with publish_actions, manage_pages authorization dialog comes with the red banner saying:
"The following permissions have not been approved for use and are not being shown to people using your app: publish_actions and
manage_pages.Submit them for review or learn more."
and
"This does not let the app post to Facebook."
. Then any attempt to post comes with Error #200) The user hasn’t authorized the application to perform this action. It I don't ask for permission I just getting Error 200.
So how exactly I can "already access these permissions and post to my Timeline or a page I admin" as an App admin?
It seems that around mid May they of went back on the review process, at least partially; if your user owns the app and the page then you should be able to publish to your stream or to your page without going through the review process... I guess you just don't have to ask for the permissions that triggers the review process.
I'll be testing this in a bit and I'll get back to you with my results.
UPDATE: Yup. I've just tested it... just ask for publish_actions, manage_pages and status_update and it'll let you autopost on your own page, just ignore the warning about the review process.

Can I change a test user's password

Is it possible to change a test user's password so I can logon to any of my test users as normal so I can test my app properly?
I've tried :
https://graph.facebook.com/{user id}?password={newpassword}&method=post&access_token={the access token}
I got the access token from the Roles screen where all my test users are listed. The above link returns :
{
"error": {
"message": "Invalid OAuth access token.",
"type": "OAuthException"
}
}
What am I doing wrong? And is there another way to change the password?
I have 15 or so test users and I need to be able to log in as any of them. Only my main test user is registered with my app, the others are friends of the main test user (this is by design)
I tried creating lots of normal users to test with and quickly realised Facebook do their best to stop people doing this
Thanks
Yes - You can. However I have tried only manually - it works.
You have to be admin of application for which users You are editing
Go to FB Developers page -> Click 'Edit Roles'
At the bottom of the page there will be all users listed, each having option to set password next to its profile photo. Just Click and change.
Hope that helps a bit. As it is not a solution to set manually password for 25 users. But if it is not possible to do it manually then it won't be possible with API. worth to try, just to identify error.
Yes - creating real users for testing purposes is not an option
This is very Easy by using even APP Dashboard as follow
All though you can use Graph API for the same ,with User APP Access Toke or User access Token (If user ID is accessed) for this Process
Here is Python script of the same
For some reason, Facebook's documentation says that you should do an HTTP POST, but the example they show uses a query string, not post data.
Try submitting all query parameters as post data:
curl -H "Content-Type: application/x-www-form-urlencoded" \
--data "access_token=<facebook app access token>&method=post&name=<full user name>&password=<password>" \
-X POST 'https://graph.facebook.com/<facebook test user id>'