Media Wiki Wikipedia Query with Multiple Categories - mediawiki

I'm trying to query Wikipedia API and retrieve the subcategories for a list of multiple categories, but it returns a 'bad title' error. I can't seem to find a solution in the documentation, anyone know if this is possible? Or do I need to run queries for one category at a time? Thanks!
Query:
https://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Ice_hockey_by_country|Category:Ice_hockey_by_city&cmprop=title&cmtype=subcat&cmlimit=50
"error": {
"code": "invalidtitle",
"info": "Bad title \"Category:Ice_hockey_by_country|Category:Ice_hockey_by_city\".",
"*": "See https://en.wikipedia.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes."
Note that this query for a single category seems to work:
https://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Ice_hockey_by_country&cmprop=title&cmtype=subcat&cmlimit=50

From what I read in the categorymembers documentation, the cmtitle parameter does not accept more than one category. It likely interpreted it as one category named Category:Ice_hockey_by_country|Category:Ice_hockey_by_city instead of the two separate categories that you intended.
I guess you'll need to query the categories separately.

Related

How to use the 'query_fields' and 'query' options with Vimeo API?

I'm trying to get my head around Vimeo API with Python. I'm successful in the sense that I can use basic API requests e.g. to list all my videos or similar.
Mostly, I use the /me/videos/ API endpoint. The API reference states, that there can be two options 'query_fields' and 'query'. If I just use 'query', I can filter the results e.g. by a string in the title. I'm assuming this works, because the default value for 'query_fields' is title,description,chapters,tags' according to the API reference.
But what i'd like to do is to use the 'query_fields' for something like:
'query_fields': 'privacy.view'
'query': 'unlisted'
But if I try that, a generic error message is returned
{
"error": "Searching for a page that does not exist or is too far back in our catalog to present.",
"link": null,
"developer_message": "The user's from + size exceeded 10,000, they requested a page of results that does not exist, or they issued an invalid query as defined in the QueryPreprocessorPlugin.",
"error_code": 2969
}
Has anyone been able to use the 'query_fields' option on any way other than the defautl fields?
You can't query any fields with query_fields, the only valid fields are the ones listed in the docs ('title', 'description', 'chapters', 'tags').
You'd need to manually filter on privacy.view, so i.e.
GET /me/videos?fields=uri,privacy.view
And loop through this filtering for the values you want.

Get users for a given group Activiti Rest API

I'm looking for some advice on how to approach retrieving the users from a given group of the activti-app. Having read the documentation I've attempted to hit the endpoint associated with users and their groups by a posting a JSON body containing an array of user task filter ids.
Testing this in Postman returns a 500 internal server error "exception": "Request method 'POST' not supported". Obviously this is because I should be making a GET request however I cannot attach a JSON body in that case.
Aforementioned example endpoint: localhost:8080/activiti-app/api/enterprise/groups/{group_id}/users
Aforementioned docs:
https://docs.alfresco.com/activiti/docs/dev-guide/1.5.0/#_user_and_group_lists
Specifically this section Screencap of activti docs
Any suggestions would be greatly appreciated!
Thanks!
First, we have to make sure we are talking about "organization groups" not "capabilities groups". That was my original confusion. Once I create the right kind of group I could successfully use the REST API to fetch both a list of groups and a list of group members.
As the docs point out, to get a list of groups, do this:
curl -uadmin#app.activiti.com http://localhost:8080/activiti-app/api/enterprise/groups
Which returns:
{
"size":2,
"total":2,
"start":0,
"data":[
{"id":5,"name":"test-org-group-1","externalId":null,"status":"active","groups":null},
{"id":6,"name":"test-org-group-2","externalId":null,"status":"active","groups":null}
]
}
If you want to pass a filter, do it with "?filter=some-group-name".
Now, to see the members of a specific group, pass in the group ID, which is a numeric. So to see the members of test-org-group-1 I would use:
curl -uadmin#app.activiti.com http://localhost:8080/activiti-app/api/enterprise/groups/5/users
Which returns:
{
"size":2,
"total":2,
"start":0,
"data": [
{"id":2,"firstName":"Test","lastName":"User1","email":"tuser1#metaversant.com"},
{"id":3,"firstName":"Test","lastName":"User2","email":"tuser2#metaversant.com"}
]
}

facebook graph comments filter and summary

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);

Displaying Album Info via JSON Facebook Graph API

I've been looking through the different threads on the Facebook Graph API and displaying the results via JSON. The examples are great but I only want to output the info for a particular album not loop through various results.
Here is a link to the Coca-Cola Wall Photos album. https://graph.facebook.com/99394368305
What I would like to do is display the Name of the Album and the Link.
Any help is much appreciated!
You can choose only the fields you want by specifying the fields query parameter:
https://graph.facebook.com/99394368305/?fields=name,link
From http://developers.facebook.com/docs/reference/api/#reading:
Selection
By default, most object properties are returned when you make a query. You can choose the fields (or connections) you want returned with the "fields" query parameter. For example, this URL will only return the id, name, and picture of Ben: https://graph.facebook.com/bgolub?fields=id,name,picture
You can also request multiple objects in a single query using the "ids" query parameter. For example, the URL https://graph.facebook.com?ids=arjun,vernal returns both profiles in the same response.

Tailoring the output of YQL

This YQL statement (execute in the YQL console) picks out the name and year of a film from the TMDB website.
select content from html where url="http://www.themoviedb.org/movie/27205" and xpath='//h3[#id="year"]|//h2[#id="title"]/a'
the results come back like this:
"results": {
"a": "Inception",
"h3": "(2010)"
}
Is there any easy way to have label the results as 'name' and 'year' rather than the html elements they were grabbed from?
Cheers!
Currently there is no easy way to quickly alias the returned labels. The best way at the moment is to create a custom data table which makes your query to TMDB and transforms the result (with Javascript, in an <execute> block) to whatever you want it to be.
For example, I created a quick custom table for you which returns the results with your labels of choice (name and year). It also removes the parentheses from around the year. To give it a test run, use:
use "store://github.com/tmdb-jp" as tmdb;
select * from tmdb where movieid="27205"
With the resulting JSON having the following structure (within the usual YQL response):
"movie": {
"title": "Inception",
"year": "2010"
}
If you want to have a go at creating a data table yourself, or just see what's involved, then the source is on my github. Also (it might be useful) you can query for multiple movies at once:
use "store://github.com/tmdb-jp" as tmdb;
select * from tmdb where movieid in ("27205","9802")
P.S. The store:// URLs just mean that the data table is being stored in Yahoo!'s "cloud" for speed and reliability. You can of course use a normal http:// URL (e.g. by github one) instead.