GET▾→ /v2.7▾/pepsi?fields=fan_count
I am new to graph API, I am interested in getting the facebook fan counts for different pages.
Using Facebook Graph API explorer, the above code gives me for only 1 page,
but if I want to get the fan counts for different pages - What should be the code ?
For example- I tried GET▾→ /v2.7▾/coke,pepsi?fields=fan_count
but got the error --
{
"error": {
"message": "(#803) Some of the aliases you requested do not exist: coke,pepsi",
"type": "OAuthException",
"code": 803,
"fbtrace_id": "FqAQ297ssFe"
}
}
https://developers.facebook.com/docs/graph-api/using-graph-api/#multiidlookup
You can make a single GET request that retrieves multiple nodes by using the ?ids endpoint with the object IDs of those nodes.
So the request you want to make is: ?ids=coke,pepsi&fields=fan_count
You can retrieve data for up to 50 objects in one go this way.
Not sure why you believe this would be possible, but you need to do two API calls for two Pages. You can only make the API calls faster with batch requests, check out the docs for more information: https://developers.facebook.com/docs/graph-api/making-multiple-requests
They still count as separate API calls though, but it will be as fast as the slowest API call in the batch.
Related
The question
My application needs to check if a specific comment, on a known video was successful sent by a user of the app.
To do this, I need to use the YouTube Data API (or perhaps so other method).
There seems to be two ways I can do this:
I get all comments sent by the channel, and filter for the specific video.
I get all comments from the specific video, and filter for the specific channel.
CommentThreads (list by channelId)
CommentThreads (list by videoId)
However, "list by video" isn't ideal since if the video has a large amount of comments, it'd be hard to find the comments by the user / take longer.
To be clear, it's not a random user, the user will give the YouTube scopes required to find such information.
The Problem
When I use the samples with the API Explorer from the YouTube Data API reference page, it simply doesn't work.
Here's the error I get:
{
"error": {
"code": 400,
"message": "The API server failed to successfully process the request. While this can be a transient error, it usually indicates that the request's input is invalid. Check the structure of the \u003ccode\u003ecommentThread\u003c/code\u003e resource in the request body to ensure that it is valid.",
"errors": [
{
"message": "The API server failed to successfully process the request. While this can be a transient error, it usually indicates that the request's input is invalid. Check the structure of the \u003ccode\u003ecommentThread\u003c/code\u003e resource in the request body to ensure that it is valid.",
"domain": "youtube.commentThread",
"reason": "processingFailure",
"location": "body",
"locationType": "other"
}
]
}
}
To be clear: I'm using the pre-made samples provided by Google themselves.
1st screenshot of "code"
2nd screenshot of "code"
So, how would I fix this and make CommentThreads (list by channelId) work?
Similar Questions
Get list of all comments made by a given user with Youtube Data API? - This question isn't exactly answered,
and since it seems they don't want to request the user's consent the comments say that it's against YouTube policy and don't really mention the YouTube Data API. But most importantly, does not mention CommentThreads (channelId). For this reason, mainly the difference in consent, I don't think my question is a duplicate.
How to get comments posted by a specific account (channel) through YouTube Data API? - This question is much closer to mine, and even mentions CommentThreads, but they ignored the obvious "list by channelId" (unless it was implemented into the API after the question was asked), regardless there was no answer to my question.
Thanks to the suggest made by #Marco Aurelio Fernandez Reyes, I looked at the IssueTracker and found that an issue that explained that this is an intended feature.
"CommentThreads (find by channelId)" is no longer supported and hasn't been for several months now.
Source material
I am using Google Geocoding API to conduct both forward and reverse geocoding work in my projects. While this API is only working for a single address or a single pair of geo coordinates per request, not for batch processing. I know I can copy and paste lines of addresses up to 250 to the Batch Geo Website to process, but it would be so limited and ineffectively to me if I did that. Initially, I called REST API by PHP curl in my codes, while for batch data I have no idea how to handle and I did not find the Batch Processing API document defining call URL, parameters, response, or status. Is there any resource I can find concerning Batch Geocoding API? By the way, I found the same issue on Timezone API.
Google Maps APIs support 1 query per request. To batch geocoding multiple address, you need to send 1 request per address. Implementation is entirely up to you.
As miguev mentioned, Google does not allow batch geocoding. However, HERE does have a batch geocoder that you can use go geocode multiple addresses in one call.
I think there is some misunderstanding when you use the word "batch geocoding".
Sending one request at the time is the way to go to implement batch geocoding service. You think the vendor would handle the batch, where in your case, the vendor lets you implement it locally.
Because your volume amount is so small,simply create a loop that runs all of your rows, one at the time, send them to the API, and gets the result back.
There are plenty API for batch geocoding our there and you should be ok using any of them.
In your case it would be like that:
start loop until end of collection
$ curl -X GET 'https://csv2geo.com/api/geocode?id={email}&key={key}&searchtext={search_text}'
get response back
{
"hum_address": "781 Tremont Street,Boston,MA,2118",
"address_components": {
"number": "781",
"street": "Tremont St",
"city": "Boston",
"state": "MA",
"country": "USA",
"zip": "02118"
},
"full_address": "781 Tremont St, Boston, MA 02118, United States",
"lat": 42.33957,
"lon": -71.08034,
"relevance": 1
}
and store it in a array collection
end look
I thought it was a simple thing but I was wrong, I would like to have the list of public events of a page (such as the redbull)
I tried this but without luck:
/14226545351/events
Also I would like to know if it was possible to search for events by keyword, I tried this but without luck:
/search?q=run&type=event
I generated an access token, with the right permissions (I think) but in both cases I read
{
"data": [
]
}
You can no longer use the /search endpoint with the following object
types:
event
group
page
user
Source: https://developers.facebook.com/docs/graph-api/changelog/breaking-changes#search-4-4
Event Search is not possible anymore, and the Events API in general is not possible as of now:
...apps currently accessing Events and Groups APIs will lose access today.
Source: https://developers.facebook.com/blog/post/2018/04/04/facebook-api-platform-product-changes/
It is currently not possible to query event data using the facebook api https://developers.facebook.com/blog/post/2018/04/04/facebook-api-platform-product-changes/
When I request a user's tagged places using the Facebook Graph API and receive back 200 places (in groups of 25, more or less) does that count as one API request or 200?
I know if I ask for 5 specific Ids it'll be counted as 5 separate API calls but I'm wondering about when you are asking for everything. You won't know how much data is coming back. If it counts as one API call then great, but if it's 200 then I'll need some mechanism to gather the data over a longer period of time.
This is the API call.
https://developers.facebook.com/docs/graph-api/reference/user/tagged_places
One call to the API is...well, one API call, obviously. If you call the API one time and get 25 items in the result, it will be one API call. You can increase the limit and it will still be one API call.
More information: https://developers.facebook.com/docs/graph-api/advanced/rate-limiting#what-do-we-consider-an-api-call-
The example in the docs shows that one request can also count as several API calls, if you ask for some specific IDs.
If you get 200 results, you either increased the limit or you used paging. Since you mentioned "in groups of 25", i assume you are using paging. Which means, you would need 8 API calls to get 200 items.
According to Facebook Platform Changelog
/v2.1/{post-id} will now return all photos attached to the post: In previous versions of the API only the first photo was returned with a post. This removes the need to use FQL to get all a post's photos.
Though this statement is applicable only for separate API calls per post that looks follows:
https://graph.facebook.com/v2.1/{post_id}?fields=attachments
Since I need to retrieve all possible data that user posts to timeline, I use corresponding feed edge to do so.
https://graph.facebook.com/v2.1/me?fields=feed
So when I make a post with more than one picture attached to it, retrieved API response doesn't reflects that (and as I understand it's is per design). However I found that Graph API Explorer allows to choose attachments edge while constructing feed query that in this case appears like this
https://graph.facebook.com/v2.1/me?fields=feed{attachments}
but execution of such request triggers "Unsupported get request" exception.
Summing it up, the whole issue with the approach to make separate API calls for pictures is that it will dramatically increase number of calls which in turn not only decreases overall performance of the processing algorithm, but also leads to failing API call limits restrictions that in my case is unacceptable.
So I'm curious, is there any possibility to retrieve all post attachments (i.e. pictures) while working with feed edge or any alternative approach?
Thanks.
This should work.
me/home?fields=attachments,<other stuff>
The issue eventually resolved itself.
I found that Graph API Explorer allows to choose attachments edge while constructing feed
query that in this case appears like this
https://graph.facebook.com/v2.1/me?fields=feed{attachments}
but execution of such request triggers "Unsupported get request" exception.
It seems like non-working attachment edge for feed was unimplemented feature or a bug, because, surprisingly, now all attachments are retrieved successfully as subattachments collection.
Thanks, everybody.