Page MenuHomePhabricator

API support for useformat=mobile
Closed, ResolvedPublic

Description

Copying request from the mediawiki-api list. Tried to get the reporter to report this themselves, but apparently the restrictions put in place after the spam attack prevented that.

http://lists.wikimedia.org/pipermail/mediawiki-api/2011-November/002431.html

Hi All,
Will the useformat=mobile be supported by MediaWiki API where appropriate?

I am able to do the following for non mobile content
$.getJSON('http://en.wikipedia.org/w/api.php?action=parse&page='+encodeURIComponent(query)+'&prop=text&format=json&callback=?', function(json) {
// do stuff
});

It would be nice if adding the parameter useformat=mobile would get the json object of the mobile page content

like http://en.wikipedia.org/wiki/Main_Page?useformat=mobile&format=json

but this link returns a file containing a json object of the page content

Regards,

Asher Szmulewicz


Version: unspecified
Severity: enhancement

Details

Reference
bz32624
TitleReferenceAuthorSource BranchDest Branch
builds-builder: bump to 0.0.80-20231023142438-55d11e16repos/cloud/toolforge/toolforge-deploy!120dcarobump_builds-buildermain
harbor: upgrade to 2.9.0repos/cloud/toolforge/builds-builder!19sstefanovaslavina/upgrade-harbormain
harbor: upgrade to 2.9.0repos/cloud/toolforge/lima-kilo!85sstefanovaslavina/upgrade-harbormain
Add repos/data-engineering/spark to trusted runnersrepos/releng/gitlab-trusted-runner!44dancyreview/dancy/add-de-sparkmain
Customize query in GitLab

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 21 2014, 11:58 PM
bzimport set Reference to bz32624.
bzimport added a subscriber: Unknown Object (MLST).

asher wrote:

This feature is supported since Dec 16th 2011 thanks to Patrick Reilly who added JSONP/callback support
It is working very well in all browsers except IE9 (yes it works in IE7 and 8)
The problem is a security problem
see http://stackoverflow.com/questions/5986772/ie9-script-response-blocked-due-to-mime-type-mismatch
the solution of the problem from the msdn guys
The problem is an X-Content-Type-Options: nosniff declaration and returning a JavaScript file without a JavaScript MIME type. This can only be fixed by either removing the nosniff declaration or by fixing the MIME type to indicate that the file is, in fact, script.
Can you please fix this
Thanks
Asher Szmulewicz

Probably better if done through the API ?

asher wrote:

You may be right since the API works in IE9
In the meantime if the response header is changed from
Content-Type:application/json (this is its value today) to
Content-Type:text/javascript
it will work also for IE9 w/o changing the X-Content-Type-Options: nosniff

Extension:MobileFrontend could provide an API to something like api.php?action=query&list=mobilecontent

asher wrote:

(In reply to comment #4)

Extension:MobileFrontend could provide an API to something like
api.php?action=query&list=mobilecontent

I thought adding the parameter useFormat=mobile (to be consistent with extension:mobileFrontend) whenever possible in the api.
I am using the following
$.getJSON('http://en.wikipedia.org/w/api.php?action=parse&page='+encodeURIComponent(query)+'&prop=text&format=json&callback=?',
function(json) {
do stuff
});
It would become
$.getJSON('http://en.wikipedia.org/w/api.php?action=parse&page='+encodeURIComponent(query)+'&prop=text&format=json&useFormat=mobile&callback=?',
function(json) {
do stuff
});

I'm currently working on this. It looks the following way: api.php?action=parse&page=foo&mobileformat=wml

As it's part of the normal API, all usual formats are supported, unlike the current hack.