In Facebook marketing API, where to set target URL of an Ad Campaign - facebook

I would like to create an Ad Campaign with the Marketing API but I don't know where I can set the target URL of this campaign.
I can set the objective of the campaign to WEBSITE_CLICKS but where to set the URL it will goes to?
If I use the Web Ads Manager, when I click create campaign and select the objective of "web site click", then I have to enter the promoted URL. But with the API I don't find where I can set this.
Thanks,
Julien

I finally found where I can find the promoted URL of my Ad.
In fact when you generate your Ad through the Web Ad Manager it will create a hidden post on the Facebook page that is used for the Ad (see this blog post). And Ad creative use an object_story_id and object_story_spec to link to it. So I can find my link in the field 'object_story_spec' of the creative.
->/v2.3/6024899447563/adcreatives?fields=object_story_spec
result:
{
"data": [
{
"object_story_spec": {
"page_id": "1574237802836192",
"link_data": {
"link": "http://www.mylink.com/destination",
"message": "Click!",
"name": "My test",
"description": " ",
"image_hash": "9b25eba026f1ad716010963db25fabb8",
"multi_share_optimized": false
}
},
"id": "6024899447563"
}
],
"paging": {
"cursors": {
"before": "NjAyNDg5ODQ0ODE2Mg==",
"after": "NjAyNDg5OTU0ODE2Mg=="
}
}
}
So the link is in object_story_spec.link_data.link of the creative of the Ad.

The Ad Set Object can contain an Promotion Object:
https://developers.facebook.com/docs/marketing-api/adset#promoted_object
Or it can be contained in the Ad Creative as a link_url:
https://developers.facebook.com/docs/marketing-api/adcreative/v2.3
If Campaign Object has the objective set ( which is optional ), ad sets and ad creative will be validated against the objective.
You may also need to query connection objects, especially if you want a specific Facebook Page or Tab:
https://developers.facebook.com/docs/marketing-api/connectionobjects/v2.3

Related

How to set the tracking_specs when creating Facebook ads?

I am trying to create an ad using the Facebook Marketing API. In order to create an ad inside a conversion based campaign, I am required to set proper tracking_specs values.
Querying existing ads (on other similar campaigns) I see the tracking spec is generally defined as follows:
"tracking_specs": [
{
"action.type": ["offsite_conversion"],
"fb_pixel": [<pixel ID>]
},
{
"action.type": ["post_engagement"],
"page": [<page ID>],
"post": [<post ID>]
},
{
"action.type": ["link_click"],
"post": [<post ID>],
"post.wall": [<post.wall ID>]
}
]
How do I find the required tracking_specs values? More specifically, how do I find the post ID and the post.wall ID accordingly for post_engagement and link_click action types?
I managed to figure it out on my own. When creating a new ad, in a conversion typed campaign, an ad data object that includes tracking specs should be provided. These tracking specs should include some reference to a Facebook pixel.
"tracking_specs": [
{
"action.type": ["offsite_conversion"],
"fb_pixel": [<pixel ID>]
},
]
The pixels data can be obtained manually via the Facebook Business Manager or via the Facebook Marketing APIs:
GET /v2.10/{ad-account-id}/adspixels HTTP/1.1
Host: graph.facebook.com
Read more in https://developers.facebook.com/docs/marketing-api/reference/ad-account/adspixels/
Regarding the post and post.wall IDs - these are automatically added by Facebook when the ad is created. So there is no need to include theses when creating the ad.
For anyone searching for an answer in 2023. asaf's answer is totally correct BUT you also need to wait until Meta Business Manager processes your campaign in order to see tracking_specs into the API and in the Business Manager itself.

How to deploy rich formatted link for facebook messenger bot in api.ai?

In api.ai,
Rich formatting is supported for skype pretty fine. Here's an example:-
Here's the code of custom payload of api.ai:-
{
"skype": {
"text": "OCAS means Online Credit Approval System.\n Click [here] (http://www.erainfotechbd.com/product/ocas-online-credit-approval-system/) for more information. ",
"attachments": [
{
"contentType": "image/png",
"contentUrl": "http://weknowyourdreams.com/images/smile/smile-07.jpg",
"name": "Profile-picture.png"
}
]
}
}
Now, I wanna do something like this in facebook messenger also. But in the api.ai doc, only audio, video and file is supported.
Is there any other way to do so for url also in messenger ?
Generally webhook responses can deliver any custom payload to most platforms that API.AI supports, so any feature supported by Facebook Messenger, Skype, Google Assistant, etc. can be utilized through API.AI. Unfortunately Facebook doesn't seem to support hyperlinked text. The closest analog I could find is a what Facebook calls a URL Button. Below is an example of how you could create a API.AI response that has a Facebook URL Button with Facebook's Button template:
{
"speech": "OCAS means Online Credit Approval System. Check your phone for more information.",
"displayText": "OCAS means Online Credit Approval System. Click here for more information: http://www.erainfotechbd.com/product/ocas-online-credit-approval-system/",
"data": {
"facebook": {
"attachment": {
"type": "template",
"payload": {
"template_type": "button",
"text": "OCAS means Online Credit Approval System",
"buttons": [
{
"type": "web_url",
"url": "http://www.erainfotechbd.com/product/ocas-online-credit-approval-system/",
"title": "Click here for more information"
}
]
}
}
}
}
}
You can use also use any other Facebook Messenger APIs by including any JSON inside the "message" attribute that you see from Facebook's Messenger documentation and it will be passed along to Facebook by API.AI
PS - the code above should produce a message that looks something like this:

Facebook connect approbation

Context: For a Hackathon I building an app (web based - Ruby on Rails) that matches people based on their commun interests. For that I want to use Facebook connect and instantaneously get a person's likes so I can match him/her with someone with similar interests.
The problem: But apparently I can't access someone's likes through Facebook connect unless my app has been approved by Facebook. But without this login there is no app (and I can't wait 3-7 business days to have a working app).
Is there a way I can get my app to work (even if it's only with a set of approved users/testers)? Or do I have to come up with a an alternative page where my users will have to manually enter their interests?
No, there's no shortcut for the Login Review. What you can do is adding specific users (via your app's dashboard) you want to test your functionality with as admins/developers/testers of the specific app.
This will allow them to be able to grant your app extended permissions as user_likes without Login Review.
Also, I think Facebook already provides an endpoint for your use case:
/{user-id}?fields=context{mutual_likes}
which will produce something like
{
"context": {
"mutual_likes": {
"data": [
{
"category": "Media/news/publishing",
"name": "Mashable",
"id": "18807449704"
},
{
"category": "Food/beverages",
"name": "Coca-Cola",
"id": "40796308305"
}
],
"paging": {
"cursors": {
"before": "MTg4MDc0NDk3MDQ=",
"after": "NDA3OTYzMDgzMDU="
}
},
"summary": {
"total_count": 2
}
}
},
"id": "123456789"
}
See
https://developers.facebook.com/docs/graph-api/reference/v2.0/user.context/mutual_likes
https://developers.facebook.com/docs/graph-api/reference/v2.0/page.context/friends_who_like
https://developers.facebook.com/docs/facebook-login/review/how-to-submit#testpermissions
https://developers.facebook.com/apps/{your_app_id}/roles/

Create a Link Ad for a Facebook object (event url)

In business manager it's possible to create a Link Ad with a Facebook Event url. I like to do the same with Facebook Ads API but facing a permissions error.
The Ad Creative of an Ad created in business manager looks like this one:
{
"object_story_spec": {
"page_id": "24188824589????",
"link_data": {
"link": "https://www.facebook.com/events/25595316793????/",
"message": "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"image_hash": "cbb1f226fd5fe47c826dd1cad117????"
}
}
}
When I am trying to create the same Ad Creative via Ads Api I get an error message like the following:
{
"error": {
"message": "Invalid parameter",
"type": "FacebookApiException",
"code": 100,
"error_subcode": 1349118,
"is_transient": false,
"error_user_title": "Disallowed Post Link",
"error_user_msg": "One or more of the given URLs is not allowed by the Stream post URL security app setting. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains. Read https://developers.facebook.com/docs/facebook-login/security/ to learn more about app settings related to security."
}
}
I get the same error if I try to create a Link Post with Graph API separately to use as object_story_id.
We really need this kind of Ads for our business. In stream ads perform much better than display ads. Is there anyway to create ads like this one via Ads API?
You should check the migration settings for your app to see if "Steam post URL security" is enabled.
This prevents URLs being posted by your app which do not link to a domain listed in your app settings.

Scope of Facebook API

I am trying to learn and create a Facebook API on the go. However, I haven't found any page on the developer pages that specifies the scope of the Facebook API in great detail. I understand public information can be accessed using Graph API. But at the same time understand that further access is possible, not sure how much though.
Is there anyway to access the 'Edit news feed options' of a user that authorizes an application?
I don't really understand what you mean by "scope", but the Graph API is not more than a series of URLs to contact the facebook servers with queries and obtain answers in form of JSON objects.
You can start learning by looking at the reference for the API here:
http://developers.facebook.com/docs/reference/api/
There are unofficial APIs for every language you can imagine, for example java: http://code.google.com/p/facebook-java-api/ , c#: http://facebooksdk.codeplex.com/ , etc.
To read the news feed, you can access it by:
https://graph.facebook.com/me/home?access_token=TOKEN (where TOKEN is the access token)
Fb will respond with a JSON object similar to the one pasted below.
{
"data": [
{
"id": "11111_1111111111,
"from": {
"name": "Name",
"id": "11111111"
},
"message": "SOME_MESSAGE",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/111111/posts/11111"
},
{
"name": "Like",
"link": "http://www.facebook.com/11111/posts/11111"
}
],
"type": "status",
"created_time": "2011-04-20T20:19:04+0000",
"updated_time": "2011-04-20T20:19:04+0000"
},
etc etc etc
],
"paging": {
"previous": "https://graph.facebook.com/me/home?access_token=TOKEN",
"next": "https://graph.facebook.com/me/home?access_token=TOKEN"
}
}
Having that, you can use the ID for the person or the message to perform new queries, as explained in the FB API page:
All of the objects in the Facebook
social graph are connected to each
other via relationships. Bret Taylor
is a fan of the Coca-Cola page, and
Bret Taylor and Arjun Banker are
friends. We call those relationships
connections in our API. You can
examine the connections between
objects using the URL structure
https://graph.facebook.com/ID/CONNECTION_TYPE.
The connections supported for people
and pages include:
Almost every information on FB is accessible through the Graph API, provided the user authorized the app with the rigth permissions:
http://developers.facebook.com/docs/authentication/permissions/