Jump to content

Topic on Extension talk:MobileFrontend

How to let mobileview api support form post

4
68.105.164.20 (talkcontribs)

I have the following html code snippet which submits the form data to the MediaWiki server. It works perfectly on my desktop browser (for both desktop view and mobile view). But it fails on my android application, which uses mobileview api (https://servername/wiki/api.php?action=mobileview) to retrieve and render webpages. I guess it fails because the response returned by the formAction is in html format. It cannot meet the expectation of the android app, i.e., a format returned by mobileview api.

Can you shed some light on how should I revise the formAction to make it works on android app?

$formAction = $wgScript.'?title='.$wcl->getNsText(NS_SPECIAL).':ProcessFormAction';

<form action=$formAction>
<input 1 ... />
<input 2 ... />
</form>
89.187.79.181 (talkcontribs)

I'm not entirely sure what you are trying to achieve here or do. You also talk about android app which confuses me - do you mean mobile web view on your android or a native application? Please give us more information or send an e-mail to mobile-l [1] to get a better response/support network

[1] https://lists.wikimedia.org/mailman/listinfo/mobile-l

68.105.164.20 (talkcontribs)

What I developed is a native android app based on PhoneGap. Inside the app, there is a mobile browser view. It sends out the following request using mobileview api.

'https://mywebsite/wiki/api.php?format=json&action=mobileview&page=' + encodeURIComponent(this.title) + '&redirects=1&prop=sections|text&sections=all&sectionprop=level|line&noheadings=true';

The response from the wiki server is in jason format, which can be further analyzed and shown on the embedded browser view.

$.each( rawJSON.mobileview.sections, function( index, section ) {
    xxxxx # append the (sub)sections to mobile view
}

My code is assumed to analyze only the response in jason format. However, the response of form submission is in html format, because the formAction does not use the mobileview api.

$formAction = $wgScript.'?title='.$wcl->getNsText(NS_SPECIAL).':ProcessFormAction';

As for me, it would be the best, if all the responses from the server are in the uniform jason format. I wonder whether there is a method for me to revise the formAction to use the mobileview api and get a jason response.

Brooke Vibber (talkcontribs)

What we generally recommend is to provide your interface as an API module as well as a Special: page form. (Preferably use one common backend implementation class which both interfaces use, rather than implementing things twice!)

Then your app can use the API method and speak JSON like with the other bits.

Reply to "How to let mobileview api support form post"