Parameters on Nested Facebook API Request? - facebook-graph-api

I am trying to make a call to Facebook using their Graph API Explorer, to try and find the following information about an ad:
Its adset,
Its branded page (if any),
Insights about its 100% video views.
To do that, I have constructed the following URL:
act_1234/ads?fields=id,adcreatives{branded_content_sponsor_page_id},insights{video_p100_watched_actions}&limit=1000
However, when I receive back the insights list, it is giving me just one row, for the last month. If I was making a call directly to insights, I would add the 'timeincrement=1' parameter to separate this out by day. Is there a way to add second-tier parameters to a nested query like this?

You can pass parameters to nested queries this way:
act_1234/ads?fields=id,adcreatives{branded_content_sponsor_page_id},insights.fields(video_p100_watched_actions).date_preset(lifetime).time_increment(1)

Related

AWS API Gateway: Get or Post for querying

I am creating an API, which is going to list me products page by page with given filter conditions.
To give a brief description, it holds a AWS Lambda behind AWS API.
I am not able to decide whether to use GET or POST.
Because querying is considered a GET operation, so this is natural choice. But having a GET operation with JSON body is not very convenient way. So basically, I am left with the choice of putting it in URL.
About POST, I wont be able to use API cache in future if required.
Please suggest the right way.
Use GET.
Many clients do not support the body for GET, use URL params instead of the body. GET can be cached, bookmarked. Also GET is a natural choice as you are not updating any data.

How to get woocommerce subscriptions list?

I want to get list of all subscriptions in the WOOcommerce products.
Is there a built-in function or i have to use WP_QUERY thing to access that particular thing ?
Try WC_Subscriptions::get_subscriptions().
Parameters for customising the output are documented in the function's doc block.

Collect all public posts in facebook using graph api

I am trying to collect all public posts from facebook using Graph api like twitter streaming.But i couldn't find out a way, i checked the graph api search function
https://graph.facebook.com/search?q=anyword
it needs a parameter or keyword for search, but i need all the public posts not specific to any keyword or any user or any page. Please help me to find out this.
It is not possible to perform such a vague search. Any type of search query require at least one parameter / criteria to be search. Even if had been possible, it would be like receivind millions of arrays in a single objects(which is practically impossible)
In your case it should be all the posts from a single user, a group or a page. You can receive real-time updates from the Graph API, but that too needs the object to be subscribed to other objects. Check the following link.
Real Time Updates

using POST request on Facebook Graph API

I want to access graph API to get the number of shares for different pages of my website. I can use the GET method to do so but I want to use POST so that I can send more url in a single request. The current implementation I have for GET is
http://graph.facebook.com/?ids=http://umairj.com/,http://umairj.com/146/how-to-clear-facebook-shares-cache/
Can anyone please help ?
This is badly documented (I mean I didn't find the information when I looked for it!), but there is way to pass all the parameters to the Graph API through POST method:
in your example, you should POST to http://graph.facebook.com/
with the following DATA:
ids=http://umairj.com/,http://umairj.com/146/how-to-clear-facebook-shares-cache/&method=GET
I'm not sure about the encoding of the POST DATA..in our case, we were just using ids=.....,.....,..... with numeric FB user ids and we didn't need to do any encoding, but you might need some url-encoding
Don't forget the &method=GET or it won't work ! It helped me break the url length limit that was causing bugs on Internet Explorer (I think RFC says 1024 characters, all browsers support much more, IE only ~4096 ) when we were passing too many ids through GET
if you wish to access non-public information, the same trick works with https://graph.facebook.com/ , provided you add &session_token=***** to your query
You can try to run a FQL query to get the stats for multiple urls. Facebook link_stat documentation has an example of how to do this. I'm pretty sure you can't POST to either the FQL query or the graph api you were using though unfortunately. Your FQL query would be:
SELECT url, share_count, like_count FROM link_stat WHERE url IN("http://umairj.com/","http://umairj.com/146/how-to-clear-facebook-shares-cache/")
Here is the url after properly url encoding the query: https://api.facebook.com/method/fql.query?query=SELECT+url%2C+share_count%2C+like_count+FROM+link_stat+WHERE+url+IN%28"http%3A%2F%2Fumairj.com%2F"%2C"http%3A%2F%2Fumairj.com%2F146%2Fhow-to-clear-facebook-shares-cache%2F"%29&format=json
Facebook provides a FQL testing tool to help.
Update: their API documention (see section titled "Delete) mentions you can do an HTTP POST to any of their methods and set the variable method to the method you want. You could try this, although this was designed for delete and put methods not available to javascript clients. It still looks like is all url based so I'm not sure it will take a form encoded parameter like you are looking to do.
I work at Facebook and I've updated our Graph API documentation to document this work around for very large requests:
https://developers.facebook.com/docs/graph-api/using-graph-api#largerequests

Facebook Page - Get Post feedback and impression via Graph API

I'm trying to get some insights on a list of Posts by a Page on Facebook.
To be specific, I want to get the information highlighted in this blog post via the API.
But I can't figure out how, anyone knows how?
As far as I know it's only possible using the "stream" table. So you've got to use FQL to query this data. Using this technique you'll only get the impressions directly. Feedback rate can be calculated by adding #comments and #likes and dividing the result by #impressions. Hope they'll add this to the insights graph api as well.
MartinHN
Refer to https://developers.facebook.com/docs/reference/api/#analytics
If you are trying to aggregate multiple pages or a page other than the requesting app then you may need grant read_insights permissions to your application.
Refer to http://developers.facebook.com/docs/reference/api/insights/