I'm having trouble to create Facebook lookalike audience through API? - facebook

lookalike audience showing disabled on audience dashboard while creating through API and showing a message "Lookalikes that contain locations are being retired and can't be used in new campaigns.
", Other hand when we creating lookalike audience without location than API giving error "(#2654) Missing Locations in Lookalike Spec: The lookalike spec must contain one of location_spec or country field to create a lookalike."

This seems to be bug on Facebook API. I also facing this issue as well. It seems like Facebook is going to remove country from lookalike spec in the future so any lookalike created with country in the spec got disabled. However, an api still require country parameter in order to create lookalike. So the best advise that I can give is to ask them to remove your account from test group by posting in the bug report like many others.
Example of bug reports

Spec should be in a similar format
"lookalike_spec": {"type": "similarity", "country": "US"}, "origin_audience_id": "123"

Related

Getting Error while creating audience of CUSTOM type through Marketing API - Facebook

I am using Facebook PHP SDK, and trying to create Audience of Custom TYPE from Marketing API, and I am getting following Error:
You'll need to agree to the Custom Audience terms before you can
create or edit an audience of CUSTOM type. To accept, go to
https://business.facebook.com/ads/manage/customaudiences/tos/?act=129260934125705.
Even though I have already accepted the term, I am still getting the error for accepting the terms.
Please find attached screenshot for Terms Acceptance.. Terms & Condition Accepted Screenshot
I would recommend checking the status of tos_accepted via Graph API explorer. You can also use it to debug your Audience Creation calls.
You can check if a Business has signed their Custom Audience terms of service, by making a GET call to an ad account owned by that Business. The ad account can’t be acting on behalf of another business, or be shared. The GET call is:
GET act_<AD_ACCOUNT_ID>?fields=tos_accepted
A sample response looks like this:
{
"tos_accepted": {
"custom_audience_tos": 1 // this means the terms were signed
},
"id": "act_<AD_ACCOUNT>"
}
Check full docs about TOS here
A bit more info on Custom Audiences
Thanks Artyom Kovalyov.. I have checked the graph API explorer, and this is what I get.
{
"tos_accepted": {
"web_custom_audience_tos": 1,
"custom_audience_tos": 1,
"value_based_custom_audience_tos": 1
},
"id": "act_129260934125705"
}
Please check and let me know if I can do something else to fix the error that I am getting..
It seems ok Vishal. Have you tried to create this same Audience via graph explorer? The ways to go from here are either filing an FB direct support case for your app, they are not usually fast to reply and not every customer is whitelisted for that.
Another assumption is if you try to do it on behalf of your customer with their account, it might be that they have to accept TOS, not you.
FB has a huge amount of setting and from the info, you provide it's pretty hard to tell what exactly fails.

How to create a Facebook ad based on a post?

After many tries, I'm not getting how we can use the Facebook API to create a simple Ad based on a Post (and it's creative) like it is possible in the Business Manager.
For example, my last attempt failed due to a problem with Instagram:
Facebook API: Instagram Account Is Missing
If there is anybody that has been able to create a basic Ad (within a given or new AdSet) based on a Post, please help me. I've seen many questons like this (especially regarding the Instagram problem) and now I'd like to have a working solution.
What exact requests have to be done or isn't it possible at all?
THe Instagram placement is added by default in the targeting, so if you want to skip it you need to specify in the targeting field when creating the adSet in the publisher field:
{
"geo_locations":{"countries":["US"]},
publisher_platforms: ['facebook'],
facebook_positions: ['feed', 'right_hand_column'],
device_platforms: ['mobile', 'desktop']
}
If you want to publish on Instagram also you should also provide an instagram actor ID: The AdsCreative should contain an extra field named instagram_actor_id also remember to add Instagram in the related targeting:
{
"geo_locations":{"countries":["US"]},
publisher_platforms: ['facebook','instagram'],
facebook_positions: ['feed', 'right_hand_column'],
instagram_positions: ['stream', 'story'],
device_platforms: ['mobile', 'desktop']
}
Reference:
https://developers.facebook.com/docs/marketing-api/guides/instagramads
https://developers.facebook.com/docs/marketing-api/guides/instagramads/ads_management/
https://developers.facebook.com/docs/marketing-api/targeting-specs/#placement
Let me know if you need more info or an answer or your other question about Instragam

Is fb graph user search api not working anymore?

https://graph.facebook.com/search?q=sharma&fields=name&type=user&access_token=
I was this URL along with access token and it was giving me user name list that i was using in my project. Only names are my requirement but when today i started to use it i am not getting any data nor any error.
Its only returning this
{
"data": [
]
}
Recently a month ago it was working for me.
Can anyone tell me if they have the same issue or if something has changed?
Is there any other was of getting users name mainly first + last name from fb?
I have found answer of my question which is Fb is no more giving user results for graph search api.
https://developers.facebook.com/docs/graph-api/changelog/breaking-changes#search-4-4
Search API
You can no longer use the /search endpoint with the following object types:
event
group
page
user
I dont know whether its a permanent revoke or temporary but it has something to do with Cambridge analytica data leak issue
https://www.google.co.in/search?biw=1360&bih=662&tbm=nws&ei=-iTXWrrkCYrxvgTTy5GgCw&q=cambridge+analytica+data+leak&oq=cambridge+analytica+data+leak
I hope it will help others to find out why their API is not working anymore.

facebook sdk / graph api - get custom audience current size?

Question - is there a way to get the current size of an audience from facebook? (if so, Java SDK details would be appreciated)
Why do I need this? - I'm looking to achieve the following in facebook using the java sdk (tech is irrelevant here - same issue regardless of api) -
Create a custom audience using a bunch of email ids.
Follow that with creating a look-alike audience based on the new audience above.
Complication - Now the above are pretty straightforward as individual steps and we are able to that with no issue. Trouble comes due to the following -
Facebook allows creation of look-alike audiences only when the origin audience has at least a 100 members.
Also, Facebook take a little time processing the first list (looking up matches etc. I guess) during which time the "size"of the custom audience is low (like 20 etc.). If I check back in like an hour or so, it would have updated with all the matches, and the size is now as expected.
Due to the above, if I follow the "create custom audience" call immediately with a "create look-alike audience" call, it will fail with the error below (have tried it multiple times) -
{
"error":{
"message":"(#1234) Source Audience is Too Small:
There are not enough people in your source in the country you chose.
Please choose a country that includes at least 100 people in your source.",
"type":"Exception-type",
"code": 1234,
"error_subcode":5678,
"fbtrace_id":"fb-trace-id"
}
}
If I try the look alike audience creation a while later, it works, cos by then the audience is processed (at least partially) and the size has gone > 100.
Solutions explored -
So one obvious way to solve this is to introduce a delay in creating the lookalike audience after having created the initial custom audience. This has its issues (most important is that it is guess work vs. a solid hand-shake).
Therefore (out of my innate need to have control) I'd like to "know" when the custom audience is ready (hence the original question above) so I can create the look-alike audience - am looking for help to see how this can be achieved?
I've looked thru facebook graph api docs here (http://restfb.com/javadoc/), scanned facebook forums here (https://developers.facebook.com/bugs/) to see if the CustomAudience has (or if there is another API) that gives the current size of an audience, but haven't found any. Any help is appreciated.
Thank you.
I guess this is already not relevant, but anyway.
You can make a GET request with a parameter "fields" set: https://graph.facebook.com/v2.10/{custom_audience_id}?fields=["approximate_count", "operation_status"]
The result you'll get shows approximate count of the CA and status (is the CA ready)
{
{
"approximate_count": 20,
"operation_status": {
"code": 200,
"description": "Normal"
},
"id": "{custom_audience_id}"
}

Why is the Graph API for querying a group URL simply returning the group ID?

When I GET /{group-id}?fields=link I get just get back {group-id}, rather than a full URL like in the case of /{album-id}?fields=link, /{photo-id}?fields=link, etc. Sample request and response for a group:
GET /v2.5/1685218945065439?fields=link
{
"id": "1685218945065439"
}
whereas an album looks like this:
GET /v2.5/1685219628398704?fields=link
{
"link": "https://www.facebook.com/media/set/?set=oa.1685219628398704&type=1",
"id": "1685219628398704"
}
According to the docs link is a valid field on the Group object. I'm using a token that has user_managed_groups. I see the same result when querying OPEN and CLOSED groups.
Just looking at the URLs of my groups by loading them in my web browser, I see that they all use the format https://www.facebook.com/groups/{group-id}/, so it's easy enough to build a URL from the {group-id}, but is that URL format something I can actually count on?
Using Graph API v2.5.
This is a field that is kept around for historical reasons. Back in the day you were able to actually set a website for a group, for example https://example.com.
This functionality has since been removed from the UI on facebook.com but the field in the API is present as older groups might have this value set, but newer groups won't have it anymore.
There has been a bug report about this as well which has been closed as 'By Design' for the reasons mentioned above https://developers.facebook.com/bugs/1495489670770155/
I filed a bug report to which the Facebook team responded that this is the intended behavior (also noted by Bjorn in his answer). See Bjorn's answer for more details.
The good news is that, according to the Facebook dev on that bug report, the format of the Group URL will always be https://www.facebook.com/groups/GROUP_ID, so there's really no need to query the API for the Group URL anyways.