facebook graph comments filter and summary - json

I'm trying to retrieve only top-level comments with a count or all comments (including replies) for a given post from the Facebook graph.
Has anyone got the Facebook graph comment filter or summary fields on comment graph calls to work? It says in the docs https://developers.facebook.com/docs/graphapi/guides/comments/ you can add a ?filter=stream and or ?summary=true to the graph url to include comment replies and or summary information (counts) in the collection of returned comments.
A hypothetical example is: for a public feed Facebook will tell you that a post has 100 comments and this number includes replies, when you actually retrieve the comments you may only get back 80 because the graph only returns top-level comments not comments and their replies.
Real example
graph.facebook.com/10151579052696276/comments/
gets all the first 25 comments from a post (using the object_id) but excludes replies. It only returns top level comments. This is a problem because the post comment count Facebook returns doesn't match the number of comments it returns. If you try and make comment pagination your screwed because its inconsistent.
To fix this i tried to add the filter stream and summary
graph.facebook.com/10151579052696276/comments/?filter=stream&summary=true
returns the exact same JSON.
I've tried including user access tokens (with all permissions) and an app token
try it yourself in the graph explorer https://developers.facebook.com/tools/explorer/
Any help would be much appreciated.

Your request Url is wrong
Delete "/" after "comments"
url should be like this;
graph.facebook.com/10151579052696276/comments?filter=stream&summary=true

Here's your answer:
>> For Comment Counts with their replies:
https://graph.facebook.com/80329313253_10153617216088254/comments?filter=stream&summary=true&access_token=yourtoken
>> For Comment Counts without their replies:
https://graph.facebook.com/80329313253_10153617216088254/comments?filter=toplevel&summary=true&access_token=yourtoken
Note: The above urls return a json object having two members (data array: which will show you the comment data, summary object: this will include a field showing total_counts)
It took long time for me to figure out that the summary is shown after all the comments array. Hope this answers your question.

I'm not sure if I understand the question entirely, but are you looking for a total number of Facebook comments for a given post? If so, this works:
https://graph.facebook.com/POST_ID/comments?summary=true&access_token=XXX
After all the comment id's, comment likes, etc there should be this summary:
summary: {
order: "chronological",
total_count: NUMBER
}

It returns the same json, because you request for a LIST of comments.
If you just want the summary, you have to avoid any pagination with the limit-parameter. try this:
graph.facebook.com/10151579052696276/comments/?filter=stream&summary=true&limit=0
in php i used this syntax:
$url="http://graph.facebook.com/?fields=og_object{comments.limit(0).summary(total_count)&10151579052696276";
$FB_Request = file_get_contents($url);

Related

What is the URL when I DELETE an object

I'm running a local server playing around with an API using Django. I have a model called 'Users' populated with a few objects, and am using DefaultRouter.
I want to know what the URL would be if I were to DELETE a specific object from this model. For example, if I wanted to GET a user with an ID of 1 in this model, the URL would be: "localhost:8000/Users/1/". What would the equivalent be to DELETE this user?
I found an explanation of this on the REST API website (below), however, I don't understand what any of the syntaxes means.
What is {prefix}, {url_path}, {lookup} and [.format]? If anyone could provide an example of what this might be using a localhost that would be really helpful.
Thanks
Let us take an example of an API (URL) to update book data with id (pk) being 10. It would look something like this:
URL: http://www.example.com/api/v1/book/10/
Method: PUT/PATCH
With some data associated.
If you want to delete you just need to change method to DELETE instead of put or patch.
Regarding your second question lets compare the url with the parameters.
prefix: http://www.example.com/api/v1/book
lookup: 10
format: It specifies what type of data do you expect when you hit the API. Generally it is considered to be json.
url_path: In general, every thing after look up except query string is considered to be url_path.

How to get all contributions of a wikipedia user?

Given a Wikipedia user/editor id and a timeframe, is there a way in Python to get details about all the contributions/edits made the user/editor? I want to fetch details like page edited, action taken, bytes added/deleted in case of revision, and comments (if any). Is this possible at all?
Many thanks!
Yes, pywikibot’s User class has a .contributions() method you can use to iterate over all contributions for a user.
It returns a generator that, for each edit, yields a tuple of (pywikibot.Page, oldid, pywikibot.Timestamp, comment). You don’t get the diff, but you can retrieve the page at this point (page.getOldVersion(oldid=…)) and do the diff from the point just before.
Simple code example:
from pywikibot import Site, User
user = User(Site(), "SanMelkote")
for page, oldid, ts, comment in user.contributions():
print(Page.title(), comment)

Unable to retrieve unlimited number of record via API

We are struggling to mine all time records for this year via API.
We have tried to include the :dont_limit_result GET variable and set it to 1, however it did not help us.
The version that we use is ACTIVE COLLAB 5.11.0, the URL we are hitting: projects?dont_limit_result=1&page=$page
Please give me some advise on how to proceed.
Most of API responses are paginated, and pagination can't be turned off using a GET switch. Instead, you should check following headers:
X-Angie-PaginationCurrentPage - indicates current page
X-Angie-PaginationItemsPerPage - indicates number of items per page
X-Angie-PaginationTotalItems - indicates number of items in the entire data set.
and walk through pages until you reach the end of data set.
Another option is to give project's filter a try. Here's an example request that will return all projects:
curl -H "X-Angie-AuthApiToken: YOUR-API-TOKEN" "http://your.activecollab.com/api/v1/reports/run?type=ProjectsFilter"
This one will return all active projects:
curl -H "X-Angie-AuthApiToken: YOUR-API-TOKEN" "http://your.activecollab.com/api/v1/reports/run?type=ProjectsFilter&completed_on_filter=is_not_set"
I'm using the php API wrapper 3.0 - how do i get the headers back to know there are more pages and then what is the correct form of the query to get further pages?
For example my basic query is:
$timeRecords = $client->get('projects/22/time-records')->getJson();
to get time records - but this only returns 100 and there are more!
Thanks,
P

WP rest api: How to get number of comments

I read all the Wordpress WP rest api document but i did not find how to limit the numbers of comments i want.
I tryed. http://mywebsite.com/wp-json/posts/999/comments?filter[comments_per_page]=1
If you're able to use version 2 of the Rest API, then the endpoint is something like the following:
domain.com/wp-json/wp/v2/comments?post=1&per_page=2
where the post parameter is the ID of the post for which you're retrieving the comments and per_page is how many to show. If you want a list of all comments, and limit them, then:
domain.com/wp-json/wp/v2/comments?per_page=2
You can also append a page parameter to show a different paged value of comments thus:
domain.com/wp-json/wp/v2/comments?post=1&per_page=2&page=3
which would return the 5th and 6th comments (page 3 of comments when there are 2 per page) for the post with an ID of 1

How to paginate with string provided in JSON result?

I am using Feedly API to access feeds from a particular rss feed. Take a look at this link (1). As you see, it only returns newest 20 items but I think it provides sort of a link to paginate to the next result. There is 'continuation' key provided in the result but it is a string and not a link.
How can I use that to fetch the next result? Is this even possible?
JSON response from the server
See http://developer.feedly.com/v3/streams/
You can pass the continuation key to get the next batch of results.
For example: https://cloud.feedly.com/v3/streams/contents?streamId=feed/http://feeds.engadget.com/weblogsinc/engadget?continuation=14de41de03e:f7bda:87649ed8