Missing redirects from Wikipedia API - mediawiki

I'm trying to get redirects for a Wikipedia page by mean of this query:
https://en.wikipedia.org/w/api.php?action=query&generator=search&format=json&gsrsearch=iiroc&gsrlimit=10&prop=pageprops|description|redirects&redirects
As you can see, the page "Investment Industry Regulatory Organization of Canada" gets no redirects:
"18847030": {
"pageid": 18847030,
"ns": 0,
"title": "Investment Industry Regulatory Organization of Canada",
"index": 1,
"pageprops": {
"page_image": "Investment_Industry_Regulatory_Organization_of_Canada_Logo.jpg",
"wikibase_item": "Q16987312"
},
"description": "organization",
"descriptionsource": "central"
}
However, if a go to https://en.wikipedia.org/wiki/IIROC I get redirected to https://en.wikipedia.org/wiki/Investment_Industry_Regulatory_Organization_of_Canada.
So why "IIROC" is not included in the redirects for "Investment_Industry_Regulatory_Organization_of_Canada"?
Thank you

You should continue your prop query until the batch is complete.
I reached the following result by continuing the query until https://en.wikipedia.org/w/api.php?action=query&format=json&prop=pageprops%7Cdescription%7Credirects&continue=%7C%7Cpageprops%7Cdescription&generator=search&redirects=1&rdcontinue=Financial_adviser%7C52889338&gsrsearch=iiroc&gsrlimit=10
"18847030": {
"pageid": 18847030,
"ns": 0,
"title": "Investment Industry Regulatory Organization of Canada",
"index": 1,
"redirects": [
{
"pageid": 18855542,
"ns": 0,
"title": "IIROC"
},
{
"pageid": 18936209,
"ns": 0,
"title": "Investment Dealers Assocation of Canada"
},
{
"pageid": 18936308,
"ns": 0,
"title": "Investment Dealers Assocation"
},
{
"pageid": 18936769,
"ns": 0,
"title": "Investment Dealers Association of Canada"
}
]
},

Related

Set Location in BIM360 Quality issue via API? (Rather than Location Details)

I am able to add Quality Issues through the BIM360 API (or associated APIs, link below) and I am able to set the Location Details. However, my customer uses the Location field, not Location Details. Is there any way to set the Location, specifically?
Here is the page for posting an item:
https://forge.autodesk.com/en/docs/bim360/v1/reference/http/field-issues-POST/
I don't see a location attribute or a location permitted attribute, just location details.
See image: https://i.stack.imgur.com/3OmZd.png
We can get the location id under the path attributes.lbs_location
{
"id": "038edfcf-t56y-4e04-a358-42c95f20c945",
"type": "quality_issues",
//...
"attributes": {
//...
"lbs_location": "d14ce3a6-e61b-4ab0-a9be-5acf7b5366df",
//...
},
// ...
}
To get corresponding location data, we need to call GET v2/containers/{containerId}/trees/{treeId}/nodes
{
"pagination": {
"limit": 2,
"offset": 0,
"totalResults": 2,
"nextUrl": null
},
"results": [
{
"id": "5add4375-f223-4201-88b9-8049e68416aa",
"parentId": null,
"type": "Root",
"name": "Project",
"description": "Project description",
"barcode": null,
"order": 0,
"documentCount": 0,
"areaDefined": false
},
{
"id": "d14ce3a6-e61b-4ab0-a9be-5acf7b5366df",
"parentId": "5add4375-f223-4201-88b9-8049e68416aa",
"type": "Area",
"name": "Area 1",
"description": "An Area 1 node",
"barcode": "ABC123",
"order": 0,
"documentCount": 2,
"areaDefined": true
}
]
}
To modify the location id for a quality issue, we can call PATCH issues/:id with the below payload:
{
"data": {
"type": "quality_issues",
"id": "038edfcf-t56y-4e04-a358-42c95f20c945",
"attributes": {
"lbs_location": "d14ce3a6-e61b-4ab0-a9be-5acf7b5366df"
}
}
}

Wikipedia Query Filter Ancestor Categories

Sending request:
{
"action": "query",
"format": "json",
"prop": "categories",
"titles": "Barry Archbold",
"redirects": 1,
"utf8": 1,
"formatversion": "2",
"clcategories": "Category:Living people" //one of this page's category
}
returns response:
{
"batchcomplete": true,
"query": {
"pages": [
{
"pageid": 40902107,
"ns": 0,
"title": "Barry Archbold",
"categories": [
{
"ns": 14,
"title": "Category:Living people"
}]...
but if I change clcategories to Category:Life which is one of the parent categories of Category:Living people according to Wiki's Category Tree, the categories array won't show in the response:
{
"batchcomplete": true,
"query": {
"pages": [
{
"pageid": 40902107,
"ns": 0,
"title": "Barry Archbold"
}
]
}
}
Is there a way to filter the response by ancestor category when query by titles?

Why Google's Places service get me the same cities two times with different attributes (place_id,coords ecc..)?

I want to get only one unique result from the web service autocomplete:
This is my request :
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=napoli ita&type=(cities)&language=en&key={API_KEY}
and this is the response
{
"predictions": [
{
"description": "Naples, Metropolitan City of Naples, Italy",
"id": "b2aaa9753e7bab447d0a3f71a2336c8bb96c3cac",
"matched_substrings": [
{
"length": 6,
"offset": 0
},
{
"length": 3,
"offset": 37
}
],
"place_id": "ChIJ6_p622YIOxMRfriMZcxDOtI",
"reference": "ClRCAAAA6jM0wQfsTkmn2G9JhSrJK1XN5mdK0nFiE_iNiSpmOpzWV9E5cE7Bn5hnxEZy7EfQrTm5uDagf82Sjc-6wBhd7ZtYgLUXArJNYcI1WogVH6USEGz0Cao3FSrzmLlNiP5zhqAaFKa_hu7uIBoAvErvdqhSfF-r7QfZ",
"structured_formatting": {
"main_text": "Naples",
"main_text_matched_substrings": [
{
"length": 6,
"offset": 0
}
],
"secondary_text": "Metropolitan City of Naples, Italy",
"secondary_text_matched_substrings": [
{
"length": 3,
"offset": 29
}
]
},
"terms": [
{
"offset": 0,
"value": "Naples"
},
{
"offset": 8,
"value": "Metropolitan City of Naples"
},
{
"offset": 37,
"value": "Italy"
}
],
"types": [
"locality",
"political",
"geocode"
]
},
{
"description": "Napoli, Metropolitan City of Naples, Italy",
"id": "4d33ea47519b8f9c04635b1a9bae12f04197b99d",
"matched_substrings": [
{
"length": 6,
"offset": 0
},
{
"length": 3,
"offset": 37
}
],
"place_id": "ChIJRw3rhP-wOxMRP2qkGuYBOxo",
"reference": "ClRCAAAAZZJtsiAUKI1qcM0-X_srZwzECGVTK4FtCwEVnUxa7xZJOV5VIyjYDXjqZ6miFEQ1_-yge9sGrbYsQAxOUgriaYZj1juHpRJiKijVRFztW40SEFtfe85oDpHJndMpB2KVxw4aFFKZyol4j79xsZ6f6GlA9osp-uSh",
"structured_formatting": {
"main_text": "Napoli",
"main_text_matched_substrings": [
{
"length": 6,
"offset": 0
}
],
"secondary_text": "Metropolitan City of Naples, Italy",
"secondary_text_matched_substrings": [
{
"length": 3,
"offset": 29
}
]
},
"terms": [
{
"offset": 0,
"value": "Napoli"
},
{
"offset": 8,
"value": "Metropolitan City of Naples"
},
{
"offset": 37,
"value": "Italy"
}
],
"types": [
"locality",
"political",
"geocode"
]
}
],
"status": "OK"
}
You can see that it return me the same city with different place id , name , coords but same type . Why this?
It looks like Google has two different localities with the same name in the same province of Italy that leads to exactly the same description in autocomplete.
Have a look at place ID ChIJ6_p622YIOxMRfriMZcxDOtI.
https://google-developers.appspot.com/maps/documentation/utils/geocoder/#place_id%3DChIJ6_p622YIOxMRfriMZcxDOtI
And now at place ID ChIJRw3rhP-wOxMRP2qkGuYBOxo
https://google-developers.appspot.com/maps/documentation/utils/geocoder/#place_id%3DChIJRw3rhP-wOxMRP2qkGuYBOxo
Both have the same name, the same administrative area level 1 and administrative area level 2. The administrative area level 3 is different, but it doesn't appear in the description of autocomplete, so you cannot distinguish these localities.
I don't have local knowledge, so I cannot say if this data is correct. If you believe this data is wrong, feel free to let Google know about this as specified in this support page:
https://support.google.com/maps/answer/3094088
Hope it helps!

Ordering of get folder items API call

I am using the get folder items API call, and I can tell from my tests that the order appears to be folders first and then alphabetical.
Is this call guaranteed to always return items in that order?
Box Platform team member here ... we do not consider the order of the results returned by any of our collections endpoints part of their public contract and they are subject to change. For GET /folders/id/items at least, the JSON response includes an order array, which shows how the response is ordered.
{
"total_count": 6,
"entries": [
{
"type": "folder",
"id": "192429928",
"sequence_id": "1",
"etag": "1",
"name": "Lebron and Friends"
},
{
"type": "folder",
"id": "192429929",
"sequence_id": "1",
"etag": "1",
"name": "Stephen Curry Three Pointers"
},
{
"type": "file",
"id": "818853864",
"sequence_id": "0",
"etag": "0",
"name": "Heat.jpg"
},
{
"type": "file",
"id": "818853862",
"sequence_id": "0",
"etag": "0",
"name": "Warriors.jpg"
}
],
"offset": 0,
"limit": 4,
"order": [
{
"by": "type",
"direction": "ASC"
},
{
"by": "name",
"direction": "ASC"
}
]
}
Note that this response can also include web links.
If your app depends on the list of items being ordered a certain way, we recommend sorting on the client.

Add Facebook json feed to a MySQL db

I guess this is a big ask. Using PHP I grab this Facebook Graph API json feed json feed link
{
"data": [
{
"id": "10369058551_10150645263758552",
"from": {
"name": "Land Rover",
"category": "Cars",
"id": "10369058551"
},
"message": "This week's Land Rover photo of the week is by Rodrigo Beja. Don't forget to submit your best photos each week to get featured.",
"link": "http://www.facebook.com/photo.php?fbid=10150645263678552&set=a.443106273551.221975.10369058551&type=1",
"icon": "http://static.ak.fbcdn.net/rsrc.php/v1/yz/r/StEh3RhPvjk.gif",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/10369058551/posts/10150645263758552"
},
{
"name": "Like",
"link": "http://www.facebook.com/10369058551/posts/10150645263758552"
}
],
"privacy": {
"description": "United Kingdom",
"value": "CUSTOM"
},
"type": "photo",
"object_id": "10150645263678552",
"created_time": "2012-02-03T17:19:03+0000",
"updated_time": "2012-02-03T22:32:28+0000",
"likes": {
"data": [
{
"name": "Mandy Elder",
"id": "100000250758731"
}
],
"count": 85
},
"comments": {
"data": [
{
"id": "10369058551_10150645263758552_6835532",
"from": {
"name": "John Sharp",
"id": "652940638"
},
"message": "This photo was used as part of the g4 challenge publicity photo pack around 2005-6 \nI remember because at the time I used it as a profile pic on msn \n\nAwesome photo - sums it up perfectly - I love it!!",
"created_time": "2012-02-03T21:39:48+0000"
},
{
"id": "10369058551_10150645263758552_6835852",
"from": {
"name": "Kathryn Piddington",
"id": "777370532"
},
"message": "Mud is good for the soul :)",
"created_time": "2012-02-03T22:32:28+0000"
}
],
"count": 14
}
},
{
"id": "10369058551_355476307803889",
"from": {
"name": "Land Rover",
"category": "Cars",
"id": "10369058551"
},
"message": "Click below to watch the new Range Rover Sport advert and catch up on the latest Land Rover and Range Rover news in this week\u2019s round-up. ",
"picture": "http://external.ak.fbcdn.net/safe_image.php?d=AQAx7xz602rfhyIn&w=90&h=90&url=http\u00253A\u00252F\u00252Fblog.landrover.com\u00252Fwp-content\u00252Fuploads\u00252F12my_rrs_044_LowRes.jpg",
"link": "http://blog.landrover.com/vehicles/the-land-rover-and-range-rover-weekly-19-3578.html#axzz1lKthI4F1",
"name": "The Land Rover and Range Rover Weekly 19 | Land Rover Blog",
"caption": "blog.landrover.com",
"description": "In this week\u2019s round-up of all things Land Rover and Range Rover, the new Range Rover Sport advert, Which? figures reveal the running costs of the Range Rover Evoque in comparison with competitors and a history of Land Rover narrated by Ranulph Fiennes.",
"icon": "http://static.ak.fbcdn.net/rsrc.php/v1/yD/r/aS8ecmYRys0.gif",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/10369058551/posts/355476307803889"
},
{
"name": "Like",
"link": "http://www.facebook.com/10369058551/posts/355476307803889"
}
],
"privacy": {
"description": "United Kingdom",
"value": "CUSTOM"
},
"type": "link",
"created_time": "2012-02-03T16:44:42+0000",
"updated_time": "2012-02-03T16:44:42+0000",
"likes": {
"data": [
{
"name": "Steve Nesbitt",
"id": "533982936"
}
],
"count": 10
},
"comments": {
"count": 0
}
},
{
"id": "10369058551_10150642499593552",
I'd like to the top level items to a mysql table, then each sub level to anaother table keeping a key / link between each table and then any sub level of a sublevel and linking this too. Is this possible?
I have got as far as this:-
$page = file_get_contents($url);
$json_output = json_decode($page, true);
I can't figure out how to loot hrough each row and add teh data to a Mysql table.
Thanks for your help in advance
Jonathan
Try to loop it as array then make sql query. Each array you put a unique key (for top level item). So, you can use your top level key to sub level foreign key..