Git Product home page Git Product logo

stereoket.oauthtitaniumtest's Introduction

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

stereoket.oauthtitaniumtest's People

Contributors

stereoket avatar zahlenhelfer avatar

Watchers

Brenton House avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.