|
| 1 | + |
| 2 | + |
| 3 | +var clientInfo = { |
| 4 | + name: 'Client Name' |
| 5 | +} |
| 6 | +var accessor = { |
| 7 | + consumerKey: 'registered consumerKey', |
| 8 | + consumerSecret: 'registered consumerSecret' |
| 9 | +}; |
| 10 | +var client = new Twitter.Client(clientInfo, accessor); |
| 11 | + |
| 12 | +client.addEventListener('unauthorized', function(e) { |
| 13 | + client.requestToken(function() { |
| 14 | + location.href = client.getAuthorizeURL(); |
| 15 | + }); |
| 16 | +}); |
| 17 | +client.addEventListener('error', function(e) { |
| 18 | + // |
| 19 | +}); |
| 20 | + |
| 21 | +function verifyClient() { |
| 22 | + var pin = document.getElementById('PIN').value; |
| 23 | + client.verifyClient(pin, function() { |
| 24 | + widget.setPreferenceForKey(client.accessor.token, 'oauth_token'); |
| 25 | + widget.setPreferenceForKey(client.accessor.tokenSecret, 'oauth_token_secret'); |
| 26 | + }); |
| 27 | + return false; |
| 28 | +} |
| 29 | + |
| 30 | +function send() { |
| 31 | + var status = document.getElementById('STATUS').value; |
| 32 | + |
| 33 | + var agent = client.createAgent('statuses/update'); |
| 34 | + agent.params = { |
| 35 | + status: status |
| 36 | + }; |
| 37 | + var req = agent.send(); |
| 38 | + req.onload = function() { |
| 39 | + if (client.handleResponseCode(req, agent)) { |
| 40 | + // |
| 41 | + } |
| 42 | + }; |
| 43 | +} |
| 44 | + |
| 45 | +function verifyCredential() { |
| 46 | + client.verifyCredentials(function(xhr) { |
| 47 | + // |
| 48 | + }); |
| 49 | +} |
| 50 | + |
| 51 | +function timeline() { |
| 52 | + var agent = client.createAgent('statuses/friends_timeline'); |
| 53 | + var req = agent.send(); |
| 54 | + req.onload = function() { |
| 55 | + if (client.handleResponseCode(req, agent)) { |
| 56 | + // |
| 57 | + } |
| 58 | + }; |
| 59 | +} |