How to get ad_id in Facebook Ads? - facebook

I want to moderate Instagram ads, but I can not access the ad_id. I have done the "http delete request" to enter the ad_id value but I get an error. How can i get the ad_id in facebook ads api?
DELETE REQUEST URL:
https://graph.facebook.com/v2.8/<ID_HASH_STRING>
BODY PARAMETERS:
{
"ad_id":"number12321435",
"access_token":"xxxxxxxxxxxx",
"appsecret_proof":"xxxxxxxxx"
}
RESPONSE:
{
"error": {
"message": "(#100) Param ad_id must be a valid Adgroup ID",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "CAwgnuVEWYl"
}
}
DOCS:
https://developers.facebook.com/docs/marketing-api/guides/instagramads/ad_creative/v2.9 (under "Post Moderation").
Thanks.

I solved this problem!
You must follow this order to get ad_id and remove comment successfully;
act_id/ads // this end-point gives you id = ad_id which is required to delete a comment or create a comment.If you want to get comments belongs to this ad_id follow order. Assume that id value is '011011011'
ad_id/adcreatives // if you use this endpoint with fileds=effective_instagram_story_id you'll get Ad Creative's Feeds with this feed id you'll get comments
effective_instagram_story_id/comments // gives you latest comments pick a comment's id
aWdfY29tbWVudDoxNz**********?ad_id=011011011 // send delete request and then it's working! As you can see that we used '011011011' id in order to delete this comment at first section.

You want to moderate an Instagram ad, but you do not have the ad id. So what do you have? Let's assume you should have your ad account id. In that case, you can use:
https://graph.facebook.com/v2.9/act_/ads?fields=name
You can see all the ads of the ad account. Based on the name, hopefully, you can tell which ad you are talking about. Or you can use some other fields to find your ad. But no matter what, you need to know your ad, before you can moderate an ad.

Related

How to get user from comment on page posts use feed

I got the comments list from the feed, but I could not get their user name and avatar, I used the graph explorer and there were no fields to retrieve the user information that was commented.
I tried, but it does not work.
{page_id}/feed?fields=id,comments{id,message,created_time}
Comment Id also doesn't support getting user information.
448052816017010_448055412683417/?fields=message
// My result
"data": [
{
"id": "448052816017010_448055412683417",
"message": "TYM TYM",
"created_time": "2019-06-24T07:20:22+0000"
}
] ...
Is there a way to get user or user id, or do I need to grant any permissions?
https://developers.facebook.com/docs/graph-api/reference/v3.3/comment
You need to ask for the correct field. id is just the id of the comment itself, not the id of the user. from would be the correct field. You have to use a Page Token of that Page, and i believe the App has to be live:
{page_id}/feed?fields=id,comments{id,message,created_time,from}
See this for additional information: Graph API: Cannot get "from" field in comment

Facebook API: Instagram Account Is Missing

whenever creating or updating an Ad's creative, I'm getting this error:
{
"error": {
"message": "Invalid parameter",
"type": "OAuthException",
"code": 100,
"error_subcode": 1772103,
"is_transient": false,
"error_user_title": "Instagram Account Is Missing",
"error_user_msg": "You're using Instagram as a placement. Please select an Instagram account to represent your business in your Instagram ads, or select a Facebook Page to use instead.",
"fbtrace_id": "..."
}
}
However, what I simply try to do is to create an Ad for a specifc Page Post and add this to an existing AdSet. To create a new creative for a given Post, I use the /adcreatives endpoint and pass the following:
POST: https://graph.facebook.com/v3.1/act_<ActId>/adcreatives
{
"name": "Test",
"object_story_id":"<PostIdWithPage>",
}
This works fine so far. But the following update of the Ad results in the error above:
POST: https://graph.facebook.com/v3.1/<AdId>
{
"creative": {
"creative_id": "<CreativeId>",
}
}
I guess, the above error happens when I try to add a creative to the Ad that can not be used on Instagram.
But why isn't it working like in the Business Manager? There, I can simply select a Post for a newly created Ad. If this Post is not valid for Instagram, it shows a warning but it still works.
So, when I want to create a tool that can create Ads based on given Posts, how can I achieve that? How can we come around the error above?
The important missing part here is, that we have to specify instagram_actor_id when creating the AdCreative. The ID can be retrieved by GETting <PageId>/page_backed_instagram_accounts.
Further to the accepted answer, I needed a little bit more information to properly connect an instagram account to my page:
There are two ways to link in instagram account to your page:
1. Setup a 'Page Connected' instagram account
Log in as a page admin, go to page settings > instagram and link
an existing instagram account to the page.
You can then get the linked instagram account id by doing a GET on:
<PageId>/instagram_accounts
2. Create a 'Page Backed' instagram account.
This is for when you don't have an existing instagram account you want to link to your page, and want to instead create a 'shadow' instagram account based off your page.
You can generate a paged backed instagram account by performing a POST on the following endpoint. And retrieve an existing one, by performing a GET.
<PageId>/page_backed_instagram_accounts
** Note that both these endpoints require you to have a 'page access token' rather than the normal 'account access token' you use to create your ads.
To get your page access token, you can do a GET request on:
/me/accounts
Then, as stated in the accepted answer - pass your new, linked instagram account id as the instagram_actor_id in your ad creative request.
Sources:
https://developers.facebook.com/docs/marketing-api/guides/instagramads/
https://developers.facebook.com/docs/facebook-login/access-tokens#pagetokens

Facebook Graph API privacy setting CUSTOM with allow return error - (#100) Only friends may be specified in allow and deny lists

I am trying to do the following in Facebook Graph Explorer using my app's token.
POST /v2.6/me/live_videos?description=hello%20world&privacy={'value':'CUSTOM','allow':'<friend id>'}&title=welcome
But I am getting the following error, am I doing anything wrong? Should the friend id be app-scoped user id instead?
{
"error": {
   "message": "(#100) Only friends may be specified in allow and deny lists",
    "type": "OAuthException",
    "code": 100,
    "fbtrace_id": "BOcQttKPs5W"
  }
}
The problem here is that you need to know so-called "app scoped user id" of the friend you want to add.

How to get User's avatar after Facebook API was changed

I have an issue the relates with Facebook API. Before, I can use the graph api like that to get user avatar
//graph.facebook.com/giuliana.roeffero/picture?type=large
But now I got this issue
{
"error": {
"message": "(#803) Cannot query users by their username (giuliana.roeffero)",
"type": "OAuthException",
"code": 803
}
}
So now, I need to use the User ID instead of User Name, like this
//graph.facebook.com/100001473111658/picture?type=large
And my question is Can we get the User Avatar by User Name via Facebook API now? If not, how can I get the User Id by User Name?
You can´t get the username at all, it was removed from the API. The only way is to use the (App Scoped) ID, just as you mentioned in your question. So this is how you get the Avatar:
Authorize the User (with no additional permissions) to get his App Scoped ID
use https://graph.facebook.com/[User-ID]/picture to get his Avatar

How can I get tagged_places of my friends?

When I submit a get on Graph API Explorer, like that:
me?fields=tagged_places
Works good and return the data of my 'tagged places' to me.
But when I try to get 'tagged places' of my friends, I got this error message:
"error": {
"message": "(#100) Unknown fields: tagged_places.",
"type": "OAuthException",
"code": 100
I want to know if is not possible to get 'tagged_places' of my friends or Im doing something wrong.
You need to have the permission of the item you were tagged in.
Take a look at this answer.
Kindly note that the field 'tagged_places' is only accessible on the User object after the user grants the 'user_tagged_places' permission.
This means
1. Your app should request for the 'user_tagged_places' permission during login
2. Your friends should approve of this request while signing into the app.
Hope this helps!