1

I am trying to make a pure JavaScript Twitter application. I'm not concerned about the security involving the tokens since this is for internal use.

Currently, my code looks like this:

    $.ajax({
        url: 'https://api.twitter.com/oauth/request_token',
        type: 'post',
        data: {
            oauth_callback: callbackurl
        },
        dataType: "jsonp",
        headers: {
            "oauth_nonce": nonce1,
            "oauth_callback": callbackurl,
            "oauth_signature_method": "HMAC-SHA1",
            "oauth_timestamp": Math.round(new Date().getTime()/1000),
            "oauth_consumer_key": "IQKbtAYlXLripLGPWd0HUA",
            "oauth_signature": "Pc%2BMLdv028fxCErFyi8KXFM%2BddU%3D", //generate
            "oauth_version": "1.0"
        },
        success: function(data)
        {
            console.info(data);
        }
    });

This code is rather incomplete, but the goal is to get what Twitter is returning (the request tokens). Obviously this code is not going to work because it violates cross origin policy. I have heard that this is possible with pure JavaScript, though. I need to send Twitter headers (at least, I think they have to be headers) then retrieve what they return.

Is there a workaround for this?

4

0 に答える 0