How do you publish status to a specific friend list? - facebook

I would like to publish a status to a specific friend list (e.g. "family" or "best friends"). I can get the ID of the friend lists using the FB API, but I don't see a way to use this ID when publishing the status.
With a group, I can just publish to the group ID (https://graph.facebook.com/groupID/feed). But this doesn't seem to work for a friend list.

This seems to do the trick:
curl -F 'access_token=your_access_token' -F 'message=your_message' -F \
"privacy={'value':'CUSTOM','friends':'SOME_FRIENDS','allow':'your_list'}" \
https://graph.facebook.com/your_id/feed

Related

Supporting multiple locales for a shared page in facebook

I'm attempting to have multiple title and descriptions for a same endpoint, one per language.
Trying to follow this documentation: https://developers.facebook.com/docs/opengraph/guides/internationalization#objects
I have a server that detects when the client is a bot, for example facebook bot, and it renders a single file with the title and description metas, and the following localization metas. I have a file for each language, and I set og:locale depending on the localization fb_locale that I recieve on the queryparams.
meta(property="og:locale" content="en_gb")
meta(property="og:locale:alternate" content="es_es")
meta(property="og:locale:alternate" content="it_it")
How can I have multiple language for the same endpoint?
This is my testing app and endpoint I'm trying to translate: https://webapp-server-21b.herokuapp.com/marcp
It seems that it crawls it properly, but does not display the preview in the language I expect when I share it on FB or in the debugger of facebook.
If I perform :
curl -X POST -F "id=https://webapp-server-21b.herokuapp.com/marcp" -F "scrape=true" -F "locale=en_gb" "https://graph.facebook.com" -s
or:
curl -X POST -F "id=https://webapp-server-21b.herokuapp.com/marcp" -F "scrape=true" -F "locale=es_es" "https://graph.facebook.com" -s
I get the expected title in the corresponding expected language, but when I share on facebook or in the debugger it's always in english, the default locale.
Thanks!

Questions about Boosted Facebook Posts

I am trying to figure out if the following is possible through the various Facebook APIs:
Create a Post on a Page through the API (I know that's possible:)
Boost that Post through the Ad API (I read that it's possible but I
can't really find the API that would let me do that. if you know it,
please point it out! Thanks!)
Once boosted, is there a way I can pull the boosted post information
from the original post? I assume that once boosted, the boosted post
is a different version of the original post, right?
I can get post stats through the Insight API and I can get boosted
post stats through the various Ad stats API. Do the post stats only
apply to the post and the boosted post stats only apply to the
boosted post or are they all one set of stats that applies to both?
Thanks in Advance!
Everything you are looking to do is available trough both the Graph API and the Marketing API.
1) Yes this is possible, as you pointed out. You can read more here
2) I would suggest that you read through the Marketing API doc I linked above to find out the full structure of an ad. But in short, an ad is split into the following 4 objects:
Ad Campaign: This is simply a grouping of Ad Sets which all have a similar business purpose as defined by the campaign objective.
Ad Set: An ad set is a group of ads that share the same daily or lifetime budget, schedule, bid type, bid info, and targeting data.
Ad Group: An ad object contains the data necessary to visually display an ad and associate it with a corresponding ad set. Each ad is associated with an ad set and all ads in a set have the same daily or lifetime budget, schedule, and targeting. Creating multiple ads in each ad set will let us optimize their delivery based on variations in images, links, video, text or placements.
Ad Creative: An ad creative object is an instance of a specific creative which is being used to define the creative field of one or more ad groups.
3) When a post has an ad created based on it there is not "duplicate" post created for the purpose of the Ad. If you want to only get paid/boosted information on the post then the best way to do this would be using the Ads Insights API.
4) When you pull stats from the insights API you will see metrics with 'paid' appended to them, for example 'post_impressions_paid'. This will return you the number of paid impressions (i.e. from an ad) but it will not give you any information on which ad caused those impressions. The Ad Insights API's will only return impressions, likes, comments etc caused by the ads that serve the post, they will NOT return organic actions.
Here is a quick run down of cURL commands that will create a campaign to boost a Post, but before trying them I would fully read the Marketing API docs so you understand whats happening.
// First we need to get the Ad Account from a user
curl https://graph.facebook.com/{USER_ID}/adaccounts&access_token={TOKEN}
// Now we can create our Ad Campaign. Response: {"id": "CAMPAIGN_GROUP_ID"}
curl \
-F 'name=my campaign group' \
-F 'campaign_group_status=PAUSED' \
-F 'objective=POST_ENGAGEMENT' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/<API_VERSION>/act_<AD_ACCOUNT_ID>/adcampaign_groups
// Using the Campaign Group ID we can create an Ad Set. Response: {"id": "AD_SET_ID"}
curl \
-F "name=My Adset" \
-F "bid_type=CPC" \
-F "bid_info={'CLICKS': 500}" \
-F "campaign_status=ACTIVE" \
-F "daily_budget=2000" \
-F "campaign_group_id=<AD_CAMPAIGN_ID>" \
-F "targeting={'geo_locations':{'countries':['US','GB']}}" \
-F "access_token=<ACCESS_TOKEN>" \
"https://graph.facebook.com/<API_VERSION>/act_<AD_ACCOUNT_ID>/adcampaigns"
// Before we create an Ad Group, it is recommended to create an Ad Creative.
// Response: {"id": "CREATIVE_ID"}
curl \
-F "name=sample creative" \
-F "object_story_id=<POST_ID>" \
-F "access_token=<ACCESS_TOKEN>" \
"https://graph.facebook.com/<API_VERSION>/act_<AD_ACCOUNT_ID>/adcreatives"
// Now that we have the Creative ID we can use that to create the final piece
// of the puzzle, the Ad Group. Response: {"id": "AD_GROUP_ID"}
curl \
-F "name=my ad" \
-F "campaign_id=<AD_SET_ID>" \
-F "creative={'creative_id':<AD_CREATIVE_ID>}" \
-F "adgroup_status=PAUSED" \
-F "access_token=<ACCESS_TOKEN>" \
"https://graph.facebook.com/<API_VERSION>/act_<AD_ACCOUNT_ID>/adgroups"

Post Open Graph Action using the App Access Token

I am trying to post an action using Facebook Open Graph API based on the Facebook documentation. When I do the following :
curl -X POST \
"https://graph.facebook.com/app/myNamespace:myAction" \
-F "access_token=$APP_TOKEN" \
-F "myObject=https://myhost.com/objectid"
I get the following error :
{"error":{"message":"(#200) Requires extended permission: publish_actions","type":"OAuthException","code":200}}
I have obtained a valid 'App Token' using this Faceboo documentation. The document states that actions can be published using App Tokens.
Btw, I am able to successfully post actions using user-access-token as follows :
curl -X POST \
'https://graph.facebook.com/me/myNamespace:myAction' \
-F 'myObject=https://myhost.com/' \
-F 'access_token=user-access-token'
Any Help is greatly appreciated.
You're trying to post to an Open Graph action as the app, which is not possible.
Unfortunately, there is no documentation to that explictly says this, but here is someone who tried to do the same thing.
If you read the documentation you posted, you'll see two main points. First, app tokens are for publishing information on the feeds of user's who have given permission to the app to do so, and app tokens are for some other basic "maintenance" type stuff for the app itself. There is nothing in there that support the idea that app tokens can be used for anything like posting regular Open Graph actions.

Is there a trick to editing the status of an Ad Group?

According to the Facebook documentation, you can update the run status of an individual ad group via the ads api.
To do this, you submit a POST request to /<AD_GROUP_ID>/ with adgroup_status=X where X is your status (1 for active, 9 for paused, etc). However, making this request results in the status NOT changing, and the only response you get back from Facebook is a JSON representation of the Ad Group.
Has anyone been able to successfully submit ad group status updates to the facebook ads api? If so, are you using the method outlined above, or is there another trick to it?
thanks!
EDIT
I cross posted this into the Facebook Bug tracker in hopes to create a trail/awareness/find more people who were having this problem. https://developers.facebook.com/bugs/354657724569051
EDIT
An example of the request I'm making. This request is being tested from the Facebook Graph Explorer
https://graph.facebook.com/6003521999629?adgroup_status=9&method=POST&access_token=<access_token>
We have not been experiencing problems with changing adgroup_status. Try submitting the status number as an integer and then as a string (I don't remember which type they expect). Note that if the campaign is paused, setting the adgroup_status to 1 will actually change it to 8 (campaign_paused). The fact that you're getting the adgroup to redownload (I presume you have the redownload=1 parameter) tells me that your call is mostly correct. I just confirmed that this works:
curl -F "adgroup_status=9" \
-F "ids=..." \
-F "access_token=..." \
https://graph.facebook.com/
If you're making that API call and receiving the adgroup's details back instead of a 'true' response, it means you're making a GET request, not a POST request.
Update your code to make a HTTP POST request, and this will resolve your issue, John Pickard's answer above is an example of making a POST request in curl, but it will change depending on your application's language and/or which Facebook SDK you're using.

Open Graph custom action that links to other user

I have question about the beta Open Graph stuffs.
The documentation I am looking at is this https://developers.facebook.com/docs/beta/opengraph/
I successfully define custom objects and actions. However, I cannot figure out how to link current user with other users.
For example, say I define a custom action 'kick'. I want the current user to be able to 'kick' one of his/her friends.
The closest object I can think of is 'profile', but when I pass user_id, 'http://www.facebook.com/profile.php?id=', or http://graph.facebook.com/, it does not work.
This is the requests I tried
POST https://graph.facebook.com/me/myapp:kick?access_token=abc&profile=http%3A%2F%2Fwww.facebook.com%2F123
POST https://graph.facebook.com/me/myapp:kick?access_token=&profile=123
POST https://graph.facebook.com/me/myapp:kick?access_token=abc&profile=http%3A%2F%2Fwww.facebook.com%2Fprofile.php%3Fid%3D123
POST https://graph.facebook.com/me/myapp:kick?access_token=abc&profile=http%3A%2F%2Fgraph.facebook.com%2F123
This is the response I get
{"error":{"message":"An unexpected error has occurred. Please retry your request later.","type":"OAuthException"}}
The profile given is for an external website. They call it external profile. Pretty misleading terms.
As you can see I used the following
curl -F 'access_token=TOKEN' \
-F 'profile=http://graph.facebook.com/zuck' \
'https://graph.facebook.com/me/MYAPP:kick'
And it gave the above.
I guess you can fill the external profile with meta info from the Facebook users and it will show alright (for example I can send the profile URL facebook.com/zuck instead), but it seems backwards, inefficient and not the intended usage.
For example feeding it my link.
curl -F 'access_token=TOKEN' \
-F 'profile=http://facebook.com/username' \
'https://graph.facebook.com/me/MYAPP:kick'
But the thing is ... I am not a musician.
It does though seem to look alright in aggregation view.
Which is interesting/weird since one of objects shown in this picture is a Facebook profile, so you would think they would give an example with Facebook profiles as objects.
Though they did say
We are now extending the Open Graph to include arbitrary actions and objects created by 3rd party apps and enabling these apps to integrate deeply into the Facebook experience
Which most likely means they want you to create arbitrary objects outside of Facebook.
Can you still link to other users?
Yes, but through tagging using tags=FacebookID1,FacebookID2 but it will be in the form of
phwd kicked a musician with Friend1 and Friend2 on [APP NAME]