Publishing Facebook Open Graph Stories from Backend - facebook

When I try to make a POST to https://graph.facebook.com/v2.4/me/<app_namespace>:<action>
with user access_token into body I'm getting the following error:
{
"error": {
"message": "(#15) This method must be called with an app access_token.",
"type": "OAuthException",
"code": 15
}
}
Why Facebook is asking me for app access_token? I want to publish a story into wall of user specified by access_token, so I really need to use the application access_code?

Check the details of your action configuration in app dashboard. On the bottom, under “Advanced Options”, there is a option “Requires App Token to Publish” – sounds like you have that set to “Yes”.
This option exists to prevent users from “cheating” by publishing actions themselves, by using their user access token for your app – for example if you have a game with an Open Graph story about the user reaching a certain level or amount of points, then you probably wouldn’t want users to be able to publish that on their own, without actually achieving the necessary level/points in your app.

Related

Facebook APP - How do I make my Facebook App Live

Am new to Facebook related stack. So, please bear if its a dumb question.
I created a Facebook App but I couldn't able to find the option to make my APP Live. Do I need to submit it for review and then only I can able to make it Live?
Also am trying to do a Facebook messaging using send API. Am getting "message": "(#803) Some of the aliases you requested do not exist: messages".
Am I missing something? Please help.
Also am trying to do a Facebook messaging using send API. Am getting
"message": "(#803) Some of the aliases you requested do not exist:
messages"
Your URL should be in this format
https://graph.facebook.com/v9.0/me/messages?access_token=<PAGE_ACCESS_TOKEN>
This means you're missing the /me object in your call. Also since, it's a POST request you need to attach a body with the following params to the call.
"messaging_type": "<MESSAGING_TYPE>",
"recipient": {
"id": "<PSID>"
},
"message": {
"text": "hello, world!"
}
Do I need to submit it for review and then only I can able to make it
Live?
According to the page you linked, you need to request pages_messaging permission and that requires App Review in order for this Send API to work in your app.
Additionally, If you want to test this in development mode, you can give a role to the user(as a developer, tester, or analytics user) you're trying to message and test with them as mentioned on the page you linked:
Apps in Development Mode, are restricted to message people that have a
role in the app. Additionally, Pages in unpublished status will only be
allowed to message people with a role on the Page.

Facebook graph API: simple search for users by name

I would like to do a simple search for users by their name from a desktop application using Facebook's graph API. The result I want to have is a list of user names and the link to their profile. I spent several hours reading the documentation but it is still not very clear to me, which access tokens I would need. I have created a developer account on Facebook and added a new app. I've got an app access token and I've tried to do a search using the following URL:
https://graph.facebook.com/search?q=john&access_token={my_app_access_token}
I got the following response:
{
"error": {
"message": "An unknown error has occurred.",
"type": "OAuthException",
"code": 1
}
}
My question now is, if it is possible to do such a simple search without user access token. So the user sitting in front of my desktop application should NOT have to enter his facebook credentials somewhere - never. Can this be done somehow?
When searching, you should provide the search type (in your case user) and to answer your question, no, a user access token is required to search, app tokens won't work for user searches (documented here)

Get name and photo from v2.0 app scoped Facebook id, without an access token

Is it possible to get name and photo from v2.0 app scoped Facebook id, without an access token?
This used to be possible in v1.0 (with original Facebook ids), see the link.
But in v2.0 with app scoped ids, I get this error:
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
This seems to me to be a common use case, where in a game, playerA is logged into Facebook and playerB is not using Facebook, and you want playerB to be able to obtain playerA's Facebook name and photo, without logging in.
That's intentional - in v2.0 no API calls can be made without an access token except the call to retrieve a user's profile picture
You should store the name in your own database, and retrieve the photo using the app scoped ID - since you'll already be deciding which users to show based on your own database you should already have both pieces of information in your system and not need to fetch anything from Facebook's API without an access token

A user access token is required to request this resource

I've developed a Facebookapp that has the "user_photos" permission. Now i've submitted the App, which is now live. I've installed it on several Facebook-Accounts of my friends... (Yes! they have granted the requested permissions)
When i now try to make an request i get the following error message
{
"error": {
"message": "A user access token is required to request this resource.",
"type": "OAuthException",
"code": 102
}
}
Here's my Request-Query:
https://graph.facebook.com/LogInIDOfMyFriendThatHasInstalledTheAPP/?fields=albums.fields(photos,name,description),email&access_token=mySecretAppToken
Ok it works if I replace the App-Token with a User-Token that is generated by an OAuth-Process or via GraphAPIExplorer but in the Documentation (https://developers.facebook.com/docs/facebook-login/access-tokens/) it is said (in Paragraph) "App Tokens" that
"App access tokens are used to make requests to Facebook APIs on behalf of an app rather than a user. [...]" and that i have to generate an other "App Accesstoken" but this also does't work.
I'm confused...
So is there something i've forgotten / missunderstood or do I have to use the oAuth-Way which means that my friends have to reauthenticate to my App every two month???
Thanks a lot!
Best regards
Mike
A few lines after in the documentation it states
App access tokens can also be used to publish content to Facebook on behalf of a person who has granted a publishing permission to your application.
This is what they mean by requests on behalf of the user.
For the albums endpoint you need a user access token.
Yes your friends need to re-authenticate your app every two months if you extend a short lived user access token. The point is not to have apps sitting around with access when the user may have forgotten them. Prompting the user to re-authenticate ensures they are still aware of these apps and can have the choice to keep or delete them

Facebook's ads api exception 294 - Managing advertisements requires the extended permission ads_management, and a participating API key

My campaign is running on FB and I want to extract daily data with the help of Ads API.
I'm using facebook ads api and I'm facing this problem every time
{
"error": {
"message": "(#294) Managing advertisements requires the extended permission ads_management, and a participating API key",
"type": "OAuthException",
"code": 294
}
}
I have created one app XYZ and using this created I created an ad campaign.
With Graph API Explorer I generated Access Token. and I give permissions also.
You have to make sure you have an application white listed to use the Ads API. Also, you need to make sure you get an access token for that white listed application. If your app is white listed, you can use the graph explorer, change the drop down to your app, click get access token and make sure you tick the ads_management permissions. Hope that helps.
You must have to extended permission for accessing facebook ads using api.
In your facebook application which one you created in facebook account .Add itme in status and review for ads_managemnt, insight.
Setting -> Status & Review -> Items in Review.
There are few way how to generate app access tokens in FB. If you want to access marketing api you should do this in page https://developers.facebook.com/apps/{YOUR_APP_ID}/marketing-api/tools/ using required options.