I am building a facebook app and for that I need to create a fake fb user for each user that signs up into my app.
Is there an api available for creating facebook users?
Any help is appreciated.
For testing purpose you can create test user with API. The document is provided here. By specifying installed=true parameter, your app is authorized by default. It's just easy as below:
curl -X POST \
-d "installed=true" \
https://graph.facebook.com/{app-id}/accounts/test-users
Related
I created Facebook developer app to let my users posting to their Facebook pages/groups via API. I completed app review process for all required permission to be able to post on pages. But I am unable to request advanced access for Groups API which is required when I want to get my app approved for these 2 permissions: groups_access_member_info, publish_to_groups.
When I add these permissions and start the app review process it shows alert that I need to add Groups API as well. Full alert message: "You must also add Groups API to this submission before you can submit for review. You must also add Groups API to this submission before you can submit for review."
This error message is clear but the problem is button is grayed out so I can't add this permission for app review process:
It says I need to make a successful API call to groups endpoint to activate that button which I did already. I waited for a week after that API call but button is inactive still.
Requests I made to make that button active:
curl -i -X POST \
"https://graph.facebook.com/v15.0/[GROUP_ID]/feed?message=Hey&access_token=[REDACTED_ACCESS_TOKEN]"
curl -i -X GET \
"https://graph.facebook.com/v15.0/[GROUP_ID]/feed?access_token=[REDACTED_ACCESS_TOKEN]"
curl -i -X GET \
"https://graph.facebook.com/v15.0/[GROUP_FEED_ID]/?access_token=[REDACTED_ACCESS_TOKEN]"
All these three calls return successful repsonses (on development mode, of course).
I'm trying to create a Facebook ad using the Facebook Marketing API. I haven't used it before and was wondering how I gain access to the API.
I have an access token with ads_management permission but are any other steps necessary and how would I then access the API?
Thank you for your help.
Along with a access token with the appropriate scope you need a ad account and a Facebook application and to authorize the account as an advertiser for the app. Add the account under Advertising Accounts within Advanced settings of your app. See also the Facebook documentation page on Marketing API access at https://developers.facebook.com/docs/marketing-api/access. For now you should follow the Development access level.
To get start with the API you'll need to know your Ad Account ID which you should have from the prior step. If not you can find it from https://www.facebook.com/ads/manager
A simple example of using the API is to make a cURL request for the id and name of your ad account. Replace with your token and with the number ID retrieved from the above step.
curl -G \
-d "fields=name" \
-d "access_token=<ACCESS_TOKEN>" \
"https://graph.facebook.com/v2.4/act_<AD_ACCOUNT_ID>/
For further API documentation see the getting started guide at https://developers.facebook.com/docs/marketing-api/getting-started and also the API overview at https://developers.facebook.com/docs/marketing-api/using-the-api.
If you talk Python, this might help. Facebook offers a business SDK that abstracts the marketing API, and that way you can access the marketing api with the facebook sdk for python. Do "pip install facebook-business", provide the creadentials and the ads account_id. You are ready to go.
from facebook_business.api import FacebookAdsApi
from facebook_business.adobjects.adaccount import AdAccount
my_app_id = ''
my_app_secret = ''
my_access_token = ''
FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token)
my_account = AdAccount('act_XXXXX')
This will help you get started:
https://developers.facebook.com/docs/business-sdk/getting-started/
https://developers.facebook.com/docs/marketing-api/sdks/
I'm just getting set up with the ads api at my work using cURL. I've been able to successfully authenticate and get data about my ads and I am now trying to create a newsfeed creative for the page. (Specifically one of the new multi product ones, but this example will just be for a basic "object_story_spec" creative).
When I try to post the creative, I get this error:
{"error":{"message":"(#272) This Ads API call requires the user to be admin of the application. User <page_id> not admin or developer for application <app_id>.","type":"OAuthException","code":272}}
Essentially it seems to be telling me that the page needs to be listed as a developer or admin on the app, but I tried this and there is no option to do that. What am I missing here? I am guessing it is some sort of issue with how I generated the access token, which is a page access token generated from the graph api using my own access token that I generated. Any help is tremendously appreciated!
Here is my code (anything in <> was redacted by me):
curl https://graph.facebook.com/act_<account>/adcreatives
-F "name=Link Page Post Ad Creative"
-F "object_story_spec={'page_id':<page_id>,'link_data':{'message':'Try it out','link':'http://example.com','picture':'http://example.com/pic.jpg'}}"
-F "access_token=<access_token>"
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>'
I would like post some message as another user (not currently using the app). Is it possible? Of course, I would like use user which allow to get access my app.
When a user goes to your app, you can ask him for the extended permissions 'offline_access' and 'publish_stream'. With these permissions, you should be able to post as that user, even if he is not currently visiting the app.
More info about extended permissions can be found at http://developers.facebook.com/docs/authentication/permissions
edit:
You can publish to the Facebook graph
by issuing HTTP POST requests to the
appropriate connection URLs, using an
access token on behalf of the user or
an application access token (for Open
Graph Pages). For example, you can
post a new wall post on Arjun's wall
by issuing a POST request to
https://graph.facebook.com/arjun/feed:
curl -F 'access_token=...' \
-F 'message=Hello, Arjun. I like this new API.' \
https://graph.facebook.com/arjun/feed
so basically you retrieve the access token when the user authorizes your application, and store it for later use.
Quote found at http://developers.facebook.com/docs/api