I have since figured out how to used cURL on Terminal. When I enter a cURL query with parameters in Terminal, I receive a huge block of un-indented text indicating the ad id, ad snapshot URL, and ad delivery start time. Unfortunately, none of the ad snapshot URLs work.
Facebook says they're supposed to look something like this:
https://www.facebook.com/ads/archive/render_ad/?id=123&access_token=<ACCESS_TOKEN>
Mine look like this (I replaced my access token with Xs):
www.facebook.com/ads/archive/render_ad/?id=215976033116557&access_token=XXXX
Even when I reformat the URL to match that of Facebook's example, the page reads: "This page isn't available
The link you followed may be broken, or the page may have been removed."
Anyone know how to solve this by chance?
Update: exported JSON result to R using rjson, links now work
install.packages("rjson")
library("rjson")
result <- fromJSON(file = "myresults.json")
print(result)
json_data_frame <- as.data.frame(result)
print(json_data_frame)
Related
I am new to tweeter api(beginner level experience), have been exploring tweeter rest api. so far I managed to read user timeline, followers count and also able to tweet.
However in a tweet, I wish to mention users by using "#" symbol.
example something like this.
This is not working, also the same case with hashtags "#"
getting error as
If I remove "#", then it works and posts a message.
Also referred the reference api https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-update
However neither could i figure out any relevant parameter that I can use nor able to find any example while surfing.
For this POC, Twitter standard api is used(Just thinking if this feature is allowed in standard api)
Thanks and appreciate any advice/guidance
Ashish
This is because of the way that Postman is encoding your request, which breaks OAuth 1.0A for Twitter. You can try the following:
Disable all params in Params tab
Open Body tab and click x-www-form-urlencoded, then add params as needed
I check a lot of documents, and flow like that:
Submit data to create Campaign, target, and AdCreative
Use ID of AdCreative to generate preview code
Display preview code to my site (to show to my user)
But I don't want to create Campaign, Targeting, and AdCreative before preview, just submit raw data of AdCreative to get preview code.
I found that doc https://developers.facebook.com/docs/graph-api/reference/generatepreviews/, and look like they can solve my problem... But it didn't work.
My test data is: https://graph.facebook.com/v2.6/generatepreviews?ad_format=RIGHT_COLUMN_STANDARD&creative={"object_story_spec":{"link_data":{"message":"msg","link":"http://kimkha.com?1","caption":"ccccc"}},"name":"NAME 1","body":"dddddd","title":"titititit","call_to_action_type":"OPEN_LINK","object_url":"http://kimkha.com"}&access_token=<token>
And the error:
{
"error": {
"message": "(#275) Cannot determine the target object for this request. Currently supported objects include ad account, business account and associated objects.",
"type": "OAuthException",
"code": 275,
"fbtrace_id": "GeckbxpU9gr"
}
}
I ran into the same problem and got past it, despite not being able to get a fully-functioning dynamic preview working. Here are some more pointers to help save others the pain.
The url needs to include an "ad account, business account or associated objects" like the error message states. For my case I used my ad account id (https://www.facebook.com/business/help/1492627900875762). The url changed to be the following base format: https://graph.facebook.com/v2.10/act_<your-app-id>/generatepreviews
When you get the response, you need to decode the body and you can use the url directly to test. I replaced \/ with /, & with & and removed the trailing slash. After this you get a url that should give you more specific error messages
I had to also specify a "page_id" parameter that the ad will be associated with. This is a sibling of "link_data" in the sample JSON listed above.
You may get error messages telling you to change the format of certain fields.
Eventually I got the error "Preview Not Available: Unable to display a preview of this ad. (fbtrace_id: Dsfql/z/qVI)" and finally lost the will to continue. The documentation is far from easy to follow and does not have clear examples.
I'm sorry I can't give a working solution, but for my case I was evaluating this API for a non-critical piece of work and timeboxing prevented me from proceeding. Hopefully I help save some time for someone else.
I ran into this problem. The solution for me was to use my app token instead of the Graph API Explorer's token. Hope this helps!
My two cents after struggling on this issue. My request had to be formatted as follows (this is using video data, but should extend to link data):
act_{ACT_ID}/generatepreviews
?ad_format=DESKTOP_FEED_STANDARD
&creative={object_story_spec:{
page_id:<PAGE_ID>,
video_data: {
image_url: <IMAGE_URL>,
call_to_action:{
type:"SHOP_NOW",
value:{
link: <URL>
}
}
}
}}
In this case, the call_to_action has to be placed inside the video_data (or link_data) parameter and has to be formatted as an object. I did also have to change & with &, as Matt mentions.
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.
I tried to get Data from Facebook Page with the graph of Facebook but I have a problem.
When I try to go on link like:
https://graph.facebook.com/ID-PAGE?access_token=MY_ACCESS_TOKEN
I always do this to have the Data from a Page but since today I have the error Message: "An unknown error has occurred".
Thanks for help.
EDIT:
The bug is fixed : https://developers.facebook.com/bugs/486654544831076/?search_id
Have a look at my answer at
How to get user email and birthday from Facebook API Version v2.4
You have to specify each field you want to query now with v2.4. If you want to explicitly use v2.3, you need to prepend your calls by /v2.3 like this:
/v2.3/{page_id}?access_token=MY_ACCESS_TOKEN
Seems like there's currently a bug regarding requests made with app access tokens instead of user access tokens:
https://developers.facebook.com/bugs/486654544831076/
At this moment, I pretty much figured out what is happening, and it looks like a bug in the Facebook API.
For v2.3 and lower:
The /PAGE-ID call will return an Unknown server error when you don't pass ?fields=username (for example). If you do pass the fields option, it will work. You can get it out of the docs.
For v2.4:
This will work, but you will miss a lot of data, so you'll also have to pass the fields options. But if you don't pass that, this version will give you back only the most basic of details. This is as described in the version release: https://developers.facebook.com/blog/post/2015/07/08/graph-api-v2.4/
So the solution for now, would be to add the ?fields= everywhere you need, or to wait for Facebook to maybe ever solve it.
(And while you're at it, you might as well upgrade to v2.4 ;-)
I was having trouble submitting an ad through the Facebook ads api, like I was doing before.
It seems a new problem has come up. The Api of course only gives me a generic error "Invalid Parameter" however in the past I noted this this comes up for basically any reason that ad creation fails and does not tell you anything specific. In a different situation I used curl to the Facebook graph because I noted that it will give you additional information. However not much more in this case. Note the error message below the code.
curl -X POST -F "name=Ad Administrator_15"
-F "campaign_id=xxxxxxxxxx995" -F "creative={'creative_id': xxxxxxxxxx795}" /
-F "adgroup_status=PAUSED" /
-F "access_token={access_token}" / "https://graph.facebook.com/v2.2/act_{account_id}/adgroups"
This is the error received
{"error":{"message":"Invalid parameter","type":"FacebookApiException","code":100,"error_subcode":1487757,"is_transient":false,"error_user_title":"Ad Ineligible for Feed Targeting","error_user_msg":"Your ad is ineligible for News Feed targeting."}}
In checking on the facebook ads error message page. The error is not even
listed, though many others are.
previously I was getting the invalid parameter message back from the API just because I had not put a payment profile on my ad account. But used curl instead to find out this message. But after that I was creating ads just fine. Seems like this is a new problem.
If I could ask Facebook directly. I would ask "Hey can you put some descriptive error messages on your failures so that developers can see how to fix problems?" I guess that's too much to ask.
Anyhow, I may note here that The Campain was newly created with the api, then the adset, then the ad creative with the ad image, all created fine with recorded IDs (I masked these ids mostly in the code shown here for security reasons). When using these id's even outside of the API with curl I get the failure noted. Here is what shows in the API for an error with the trace.
Invalid parameter
/var/www/turnkey/vendor/facebook/php-ads-sdk/src/FacebookAds/Http/Client.php(191): FacebookAds\Http\Exception\RequestException::create(Array, 500)
#1 /var/www/turnkey/vendor/facebook/php-ads-sdk/src/FacebookAds/Http/Request.php(276): FacebookAds\Http\Client->sendRequest(Object(FacebookAds\Http\Request))
#2 /var/www/turnkey/vendor/facebook/php-ads-sdk/src/FacebookAds/Api.php(140): FacebookAds\Http\Request->execute()
#3 /var/www/turnkey/vendor/facebook/php-ads-sdk/src/FacebookAds/Api.php(182): FacebookAds\Api->executeRequest(Object(FacebookAds\Http\Request))
#4 /var/www/turnkey/vendor/facebook/php-ads-sdk/src/FacebookAds/Object/AbstractCrudObject.php(248): FacebookAds\Api->call('/act_xxxxxxxx40...', 'POST', Array)
#5 /var/www/turnkey/application/modules/Ads/models/FacebookAdsApi.php(473): FacebookAds\Object\AbstractCrudObject->create()
Here is a thought, if anyone, including someone at Facebook since they own this site, could tell me what is going on, I would really appreciate it.
Thanks in advance.
The Facebook documented required length for the message body for an ad Creative is that it needs to be a minimum length of 1 character and a maximum length of 90 characters. Before what would happen is that ads could be created. Even with test content in the title and body of your ad. Then they would not be approved if Facebook did not like the content. Such as messages like "test title, test body" and things like this. Facebook seems to be evaluating the text on submission now, rather than on ad approval. I guess they want to cut down on unnecessary ad approvals. So with out updating their documentation. It seems there are new requirements for the body field. And perhaps the title field.
All I did was lengthen the body of the ad message from 17 characters to 38 characters. This did one of two things. It made the field long enough to pass a new undocumented restriction, or, by adding some more words to the text they decided that it wasn't test message.
Here is the problem with that thinking on their part though.
1 I am paying for the ad, I should be able to put the content I want in it. As long as it is meaningful and doesn't violate some obvious certain policies for content such as obscenity etc.
2 If it's about the length rather than the content. My ad that I am paying for that only has 17 characters, should be required to be longer if I just want to say something short.