Skip to content

stereoket/oAuthTitaniumTest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This example app contains the twitter oAuth library.

the app example sends debug messages onto the screen as certain events occur, you can also test various twitter options.

You are required to add the token and secret from your twitter app in the /lib/twitter_api.js file.

1) Sign In - loads a webview up
2) close/cancel buttons on this modal window
3) PIN retrieval and local saving of return tokens for authenticated requests
4) POST a test status update 
5) GET verify credentials (data on the logged in user)
6) CLEAR / destroy the local token file.
7) API requests work on both android and iOS
8) 1.7.2 tested

KNOWN ISSUES
============

Queueing does not work, you have to sign in first then use the API calls.
Clearing local token file data will then require you to restart, unti then API calls still occur
callbacks and code structure needs to nbe reviewed and tightened
printMessage function is a little skewey in android.

The core library which is in another github project has not yet been brought up to date with this test app, I will decide if it should be maintained
seperately.


// Twitter API instructions only

create an init() function of some sort to load up all of the dependencies
Ti.include('lib/sha1.js');
Ti.include('lib/oauth.js');
Ti.include('lib/oauth_adapter.js');
Ti.include('lib/twitter_api.js');

You can set this up any way you feel fit, and store them in different directories. The order of loading is important.

This version of the script is still a little rough and can do with some tidying up.

twitter_api.js requires your secret and key information.

Main Issues:
===========

GET & POST both work
Web Pin scraping method used to authenticate, although there are other ways which I will explore in time.
process queue does not work, so you will need to authenticate and then use the api calls. I will figure out how best to queue
the calls up and update this script to streamline its behaviour.


The best method of sending a POST or GET is to run a check for the tokens file if found then set up a send request in the following format:

eg. POST (Status Update)
if (oa.TokensPresent === true) {	
oa.oAuthAdapter.send({
	url:'https://api.twitter.com/1/statuses/update.json', 
	parameters:[
		['display_coordinates','true'],
		['place_id','8ef32ff56ef11c22'],
		['include_entities',1],
		['status', 'It\'s now '+d+'. Testing twitter mobile app using http://goo.gl/sQxUE on '+ Ti.Platform.name +' #appcelerator']
	],
	method:'POST',
	onSuccess:function(response){
		rText = JSON.parse(response.responseText);
	},
	onError:function(response){
		alert(response.errorMessage);
		rText = JSON.parse(response.responseText);
	}
});

}

oa.TokensPresent will be true if tokens file is present / false if not, you can then invoke the auth process if required using:

oa.twitterAuth();

TO send a GET request, just change the method from 'POST' to 'GET' - to understand this further, please look at the testWindow.js file.

You will want to set up a function or callback from within the onSuccess events so that you can manipulate the return data.



You can make donations here if it works for you and you wish to support: 
http://goo.gl/h4UKN (pay pal link) or via my site:
http://www.stereoartist.com/projects.php


Ketan Majmudar

About

A simple console/output debugging app for testing my oauth-adapter fork - allows you to get up and running with simple twitter post/get calls

Resources

License

Unknown, Unknown licenses found

Licenses found

Unknown
LICENSE
Unknown
LICENSE.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published