Skip to main content
replaced http://stackapps.com/ with https://stackapps.com/
Source Link

I haven't used PhoneGap yet, but they claim that you develop apps with plain old JS, CSS, and HTML.

If that's true, then use the API just like you would from a web page -- with simple AJAX calls.

Here's a working example (using jQuery):

var userID      = 1416412;
var pageNum     = 1;
var pageSize    = 100;
var siteParam   = 'stackoverflow';
var appKey      = 'Get your own key!';

$.ajax ( {
    type:       'GET',
    url:        'https://api.stackexchange.com/2.1/users/' + userID
                + '/answers?page=' + pageNum
                + '&pagesize=' + pageSize + '&order=desc&sort=votes'
                + '&site=' + siteParam
                + '&filter=!3u0zcO(lpHVEGuskA&key=' + appKey,
    dataType:   'JSON',
    cache:      true,
    success:    function (apiJson) {
                    //-- Provide a closure.
                    console.log (apiJson);
                }
} );

[Get a key][1], it greatly increases your quota and is needed if you want one of the methods that needs authentication.

Reference the API docs and the API “Hello World” codeAPI “Hello World” code.

I haven't used PhoneGap yet, but they claim that you develop apps with plain old JS, CSS, and HTML.

If that's true, then use the API just like you would from a web page -- with simple AJAX calls.

Here's a working example (using jQuery):

var userID      = 1416412;
var pageNum     = 1;
var pageSize    = 100;
var siteParam   = 'stackoverflow';
var appKey      = 'Get your own key!';

$.ajax ( {
    type:       'GET',
    url:        'https://api.stackexchange.com/2.1/users/' + userID
                + '/answers?page=' + pageNum
                + '&pagesize=' + pageSize + '&order=desc&sort=votes'
                + '&site=' + siteParam
                + '&filter=!3u0zcO(lpHVEGuskA&key=' + appKey,
    dataType:   'JSON',
    cache:      true,
    success:    function (apiJson) {
                    //-- Provide a closure.
                    console.log (apiJson);
                }
} );

[Get a key][1], it greatly increases your quota and is needed if you want one of the methods that needs authentication.

Reference the API docs and the API “Hello World” code.

I haven't used PhoneGap yet, but they claim that you develop apps with plain old JS, CSS, and HTML.

If that's true, then use the API just like you would from a web page -- with simple AJAX calls.

Here's a working example (using jQuery):

var userID      = 1416412;
var pageNum     = 1;
var pageSize    = 100;
var siteParam   = 'stackoverflow';
var appKey      = 'Get your own key!';

$.ajax ( {
    type:       'GET',
    url:        'https://api.stackexchange.com/2.1/users/' + userID
                + '/answers?page=' + pageNum
                + '&pagesize=' + pageSize + '&order=desc&sort=votes'
                + '&site=' + siteParam
                + '&filter=!3u0zcO(lpHVEGuskA&key=' + appKey,
    dataType:   'JSON',
    cache:      true,
    success:    function (apiJson) {
                    //-- Provide a closure.
                    console.log (apiJson);
                }
} );

[Get a key][1], it greatly increases your quota and is needed if you want one of the methods that needs authentication.

Reference the API docs and the API “Hello World” code.

Source Link
Brock Adams
  • 13k
  • 5
  • 39
  • 64

I haven't used PhoneGap yet, but they claim that you develop apps with plain old JS, CSS, and HTML.

If that's true, then use the API just like you would from a web page -- with simple AJAX calls.

Here's a working example (using jQuery):

var userID      = 1416412;
var pageNum     = 1;
var pageSize    = 100;
var siteParam   = 'stackoverflow';
var appKey      = 'Get your own key!';

$.ajax ( {
    type:       'GET',
    url:        'https://api.stackexchange.com/2.1/users/' + userID
                + '/answers?page=' + pageNum
                + '&pagesize=' + pageSize + '&order=desc&sort=votes'
                + '&site=' + siteParam
                + '&filter=!3u0zcO(lpHVEGuskA&key=' + appKey,
    dataType:   'JSON',
    cache:      true,
    success:    function (apiJson) {
                    //-- Provide a closure.
                    console.log (apiJson);
                }
} );

[Get a key][1], it greatly increases your quota and is needed if you want one of the methods that needs authentication.

Reference the API docs and the API “Hello World” code.