How to get Campaign Summary in Facebook Graph API - facebook-graph-api

I am trying to get the summary from multiple campaigns from the facebook graph api. I already managed to get a filtered view, so i just get the Campaigns i need:
I am able to get the reach and impression data by platform for every Campaign, but if i sum it up, its not the same result as marked in the screenshot.
https://graph.facebook.com/v14.0/act_BUSINESS_ID/campaigns?fields=name,id,status,objective,insights{impressions}&filtering=[{field: "id",operator:"IN", value: ['CAMPAIGN_ID1"','CAMPAIGN_ID2"']}]
Is it possible to get the reach and impression Data as a summary and breakdowned by platform like in the Screenshot?

So, finally i got the right way!
The call should look like this:
act_Accunt_id/insights?breakdowns=publisher_platform&fields=ad_id,clicks,unique_clicks,cpm,impressions,reach,spend&default_summary=true&date_preset=maximum&filtering=[{field: "campaign.id",operator:"IN", value: ['ID1','ID2']},{"field":"publisher_platform","operator":"CONTAIN","value":"facebook"}]
I just came up with also filtering by publisher_platform and thats it!
You can filter any campaign field and as long, as you set the default_summary and the date_preset values correctly, the numbers are exact.

Related

Facebook graph api get posts after a certain post id

I am using facebook graph api where I periodically call: https://graph.facebook.com/cnn/posts?access_token=accesstoken
I don't want to get repeat posts the second time I make the call so I would like to filter the call to get anything after either a certain post Id or after a created_time. Is this possible?
I have tried using date_range= but it did not work plus it only allowed me to search by date but not time.
Use timebased paging: https://developers.facebook.com/docs/graph-api/using-graph-api/#paging
The correct parameter would be since and until. Just store the timestamp of the last post and use it in your next call.

Musicbrainz querying artist and release

I am trying to get an artist and their albums. So reading this page https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2 i created the following query to get Michael Jackson's albums
http://musicbrainz.org/ws/2/artist/?query=artist:michael%20jackson?inc=releases+recordings
My understanding is to add ?inc=releases+recordings at the end of the URL which should return Michael Jackson's albums however this doesnt seem to return the correct results or i cant seem to narrow down the results? I then thought to use the {MBID} but again thats not returned in the artists query (which is why im trying to use inc in my query)
http://musicbrainz.org/ws/2/artist/?query=artist:michael%20jackson
Can anyone suggest where im going wrong with this?
You're not searching for the correct Entity. What you want is to get the discography, not artist's infos. Additionally, query fields syntax is not correct (you must use Lucene Search Syntax).
Here is what you're looking for:
http://musicbrainz.org/ws/2/release-group/?query=artist:"michael jackson" AND primarytype:"album"
We're targeting the release-group entity to get the albums, searching for a specific artist and filtering the results to limit them to albums. (accepted values are: album, single, ep, other)
There are more options to fit your needs, for example you can filter the type of albums using the secondarytype parameter. Here is the query to retrieve only live albums:
http://musicbrainz.org/ws/2/release-group/?query=artist:"michael jackson" AND primarytype:"album" AND secondarytype="live"
Here is the doc:
https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2/Search
Note that to be able to use MB's API you need to understand how it is structured, especially, the relations between release_group, release and medium.

How do I save the web service response to the same excel sheet I extracted the data from?

For example:
The given sample HP Flights SampleAppData.xls and using the CreateFlightOrder, we can link the data to the test functions and get a OrderNumber and Price response from the Web Service. And in the SampleAppData.xls Input tab, we can see that there is a empty column of OrderNumber.
So here is my question, is there any ways that I can take the OrderNumber response and fill the empty column in SampleAppData.xls?
My point to do this is because, let's say I have many test cases to do and will take days, and today I do this certain test and I would need the result of today for the next day's test.
Although I know that the responses are saved in the result but it beats the point of automation if I am required to check the response for each and every test cases?
Yes of course you can. There are a number of ways to do this. The simplest is as follows.
'Datatable.Value("columnName","sheetName")="Value"
DataTable.Value(“Result”,”Action1”)=“Pass”
Once you have recorded the results in the Datasheet, your can export them using
DataTable.ExportSheet("C:\SavePath\Results.xls")
You can write back the response programatically , if you already imported mannually .
You can use GetDataSource Class of UFT API , it will work like this lets say you imported excel from FlightSampleData.xls, and named it as FlightSampleData, you have sheet, accessing the sheet will be like below:
GetDataSource("FlightSampleData!input).Set(ROW,ColumnName,yourValue);
GetDataSource("FlightSampleData!input).Get(ROW,ColumnName);
for exporting you can use ExportToExcelFile method of GetDataSourse class after your test run . Please let me know if you have any furthur question about this.

Find User's First Post?

Using the Graph API or FQL, is there a way to efficiently find a user's first post or status? As in, the first one they ever made?
The slow way, I assume, would be to paginate through the feed, but for users like me who joined in 2005 or earlier, that would take a very long time with a huge amount of API calls.
From what I have found, we cannot obtain the date the user registered with Facebook for a good starting point, and we cannot sort by date ascending (not outside of the single page of data returned) to get the oldest post on top.
Is there any reasonable way to do this?
you can use facebook query language (FQL) to get first post information.
Please refer below query for more details :-
SELECT message, time FROM status WHERE uid= me() ORDER BY time ASC LIMIT 1
Please check and let me know in case of any issue.
Thanks and Regards
Durgaprasad
I think the Public API is limited to the depth of information it is allowed to query. Facebook probably put in these constraints for performance and cost concerns. Maybe they've changed it. When I tried to go backwards thru a person's stream about 4 months ago, there seemed to be a limit as to how far back I could go. Maybe it's a time limit or a # posts back limit. If you know when your user first posted, then getting to it should be fairly quick using the since/until time stamps in your queries.

Duplicate photos being returned whenever i query the 'photo tags' graph api

Im making a request to the graph api in the following format to get PHOTO TAGS for a user :
https://graph.facebook.com/me/photos?access_token={0}&format=json&since={1}&until={2}&limit={3}&fields=tags,id
Since i'm doing a query for anything up to 5 years period, i've tried splitting this request into
a) chunks of 2-12 months at a time
b) one big chunk
... But no matter what i do, im getting back duplicate photo's (i've checked this by grouping the results by id and getting batches of duplicate id's). If i ask for the WHOLE set of photo tags for a user, i get back 5 duplicates. If i chunk the request it appears to bring back even more.
Any reason why i might be getting duplicates? I've checked my logic and the date ranges all appear to be fine when making the requesr
Would there be a better way of doing this query - perhaps by doing the chunk via photo creation date rangs perhaps?
When I HTTP Get me/photos?fields=tags,id, I get two objects: .data and .paging. I would suggest, rather than using your own navigation, using the paging.previous and paging.next properties to navigate up/down the photos. If you still get duplicates, then it would be a bug that you can report to https://developers.facebook.com/bugs.