Unable to get ad preview using facebook graph api? - facebook

Using the information from this documentation to generate iframe of the ad preview (in Facebook Graph API),
According to the documentation, we need to use the following URL
https://graph.facebook.com/v2.8/{adgroup-id}/previews/ad_format=
Not able to understand how to pass in the ad_format. It is compulsory to pass this parameter.

GET parameters are passed like:
https://graph.facebook.com/v2.8/{adgroup-id}/previews/?ad_format=DESKTOP_FEED_STANDARD

This question is old. But in order to run a preview you need to pass two parameters:
ad_format
There are various types of ad_formats: You generally use them according to your specific use. For basic mobile and desktop testing
DESKTOP_FEED_STANDARD, MOBILE_FEED_BASIC, MOBILE_FEED_STANDARD, MOBILE_FULLWIDTH will work fine
access_token
So your URL will be of the format :
https://graph.facebook.com/v4.0/AD_ID/previews?access_token=ACCESS_TOKEN&ad_format=DESKTOP_FEED_STANDARD

Related

Provide array of URNs to LinkedIn REST API?

I am using the LinkedIn Marketing Development Platform where I am trying to provide a list of company URNs to to the Ad Analytics API. However, when I try to provide a list of company URNs, it fails with status 400.
Analytics Finder endpoint docs
My request:
GET https://api.linkedin.com/v2/adAnalyticsV2?q=analytics&pivot=CAMPAIGN&dateRange.start.day=1&dateRange.start.month=1&dateRange.start.year=2017&timeGranularity=ALL&companies=urn:li:organization:1234,urn:li:organization:5678
Response:
{"message":"Array parameter 'companies' value 'urn:li:organization:1234,urn:li:organization:5678' is invalid. Reason: Deserializing output 'urn:li:organization:1234,urn:li:organization:5678' failed","status":400}
I have also tried URL encoding the URL, and providing the list via the parameter companies[0] as is done in other examples in the docs.
What is the correct way to input arrays to the LinkedIn API?
Edit: Changed accounts to companies
So the Protocol Version actually gave me some useful insight. There are a couple of ways of providing arrays in parameters.
From the docs:
For Restli V1.0 (used by default)
GET GET https://api.linkedin.com/people?ids=1&ids=2&ids=3
For Restli V2.0, which you can use by setting the following header: X-RestLi-Protocol-Version: 2.0.0
Pass parameters in List format.
GET https://api.linkedin.com/v2/people?ids=List(1,2,3,4)
However, I have not managed to get the Analytics Finder API to work with Restli V2.0.
You'll need to provide the list of URL encoded organization URNs to the accounts param. Using your request as an example:
&accounts=List(urn%3Ali%3Aorganization%3A1234,urn%3Ali%3Aorganization%3A5678)

Getting Feed data from Facebook API in a specific type

I want to get my feed data those type will be only video using facebook graph api.
I am using this way but not work
me/feed/?type=video&fields=shares,likes.summary(true),created_time,comments.summary(true),
actions,name,description,link,picture,type,message,status_type,story,from
Have a look at the docs at
https://developers.facebook.com/docs/graph-api/reference/v2.4/user/feed/#read
There is no such thing as a type parameter/filter. You need to use the filter parameter, with a value of app_2392950137 (video) as outlined in the docs, e.g.
/me/feed?filter=app_2392950137&fields=shares,likes.summary(true),created_time,comments.summary(true),
actions,name,description,link,picture,type,message,status_type,story,from

How can I export the feed from a group using Graph API?

I want to export the data of my Facebook group to some sort of file for historical purposes. I understand how to use the API but I don't know what I need to do to work with it. I can make queries in the explorer but it takes way to long for it to execute. I want to know what I need to do to export the data from my group into say a text file. Even just the basic steps in order to use the API would help. Thanks
You'll need to use one of the Facebook SDK's in order to programmatically access the Facebook API. Some popular ones are the JavaScript and PHP SDK's. The docs for each contain how to make API calls, and then you can use your code to handle the response to do whatever you want with them (as long as you stay within Facebook's policies).
An example of an API call in Facebook would be (after loading the SDK and having a valid login):
FB.api('/me', function(response) {
alert(response.name);
});
Let me know if that makes sense, or if you're still unclear how to approach API calls.
You have to get the feeds of the group first using graph api. Here is the code for that.
$groupFeeds = $facebook->api('/GROUP_ID/feed/?access_token='.$accessToken);
Note : $facebook is the object created of facebook class.
You have get the access token. Also you have should have the user_group permissions to extract the feeds of group.

/act_{account-id}/adcreatives creative_ids parameter is not working in the Facebook Ads Graph API

I have an application that uses the Facebook Ads OLD REST API and recently I heard that it will be deprecated in a month, so I'm working hard to migrate all my code to the new Graph API...
Unfortunately, nothing goes smoothly.
when calling to GET /act_{account-id}/adcreatives to get the AdCreatives for a specific campaign the parameter creative_ids is not working and always retrieving all the creative for the account!
This was working fine in the rest api... and no documentation changes were made in ads.getCreatives so I'm assuming creative_ids paramter is still there...
Any help will be appreciated!
thanks,
Yaniv Hakim
I found the _ids parameters to be finicky so I use the generic ids=comma-separated list parameter, without the act_{account-id}. Creative IDS are unique across accounts so there's no need to specify the account-id. If you want to use the specific parameters, have you tried creative_id, creativeids, creativeid and other permutations you can think of (with and without account-id)?

iPhone facebook integration

I am using Graph API in my application. I am fetching user's facebook wall feeds using graph API also getting details of particular post i.e (Like count,Comments etc).
but i want to allow user to Like and Comment any post from the application itself.
what is the request format for that?
Please help me or give any pointers.
Regards,
Sanket
You would be well served to check out the Publishing section of the documentation. It provides information such as this.
One example is liking, which is defined as:
Method: /OBJECT_ID/likes
Description: Like the given object (if it has a /likes connection)
Arguments: none
Basically, just initiate a Graph API call to something like:
[facebookObject requestWithGraphPath:#"98423808305/likes" andDelegate:self];
That will "like" a picture from Coca-Cola (ID taken from the documentation).
Edit 1
According to the documentation:
Most write operations require extended permissions for the active user. See the authentication guide for details on how you can request extended permissions from the user during the authentication step.
Are you sure you have enough privileges? Unfortunately the documentation is very unclear as to whether it serves the dual purpose of liking the object and returning the likes already on that object.
Edit 2
I did some more research into what could be causing this and came across this question and answer that indicated that the code I posted above using requestWithGraphPath:: should work. However, it does not due to a bug on Facebook's Bug Tracker.
Unfortunately, it looks like there is no way to "like" an object via the Graph API, which seems very strange to me. Perhaps it is possible with the legacy REST API instead of the Graph API?
Edit 3
Well, it looks like your best bet is the stream.addLike method of the legacy REST API which you can still call using the Facebook iOS SDK. You should be able to use the stream.addLike method to "like" something in the "stream". Unfortunately, it doesn't appear to support photos, videos, etc. Only posts and comments.
Finally i found the solution for LIKE option
We should use following method for like option.
-(void) requestWithGraphPath:(NSString *)graphPath
andParams:(NSMutableDictionary *)params
andHttpMethod:(NSString *)httpMethod
andDelegate:(id <FBRequestDelegate>)delegate
graphPath = /OBJECT_ID/likes
Paramas = dictionary with comment ,for like option use empty dictionary
HttpMethod should be POST
you should get response = true if the LIKE request is successful.