Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug? #6

Open
AussieBattler opened this issue May 12, 2011 · 9 comments
Open

Bug? #6

AussieBattler opened this issue May 12, 2011 · 9 comments

Comments

@AussieBattler
Copy link

Hi. Hope you can help. I have the demo Birdhouse app installed and this works correctly with my Twitter app details. I am simply trying to allow a user to send a tweet when a button is clicked. Below is my code (I have removed the key and secret code) - and this code is using the exact same auth details as the Birdhouse app which is working. However, when I run my app it does not remember that authorisation has already been given nor does it post the Tweet. Any ideas on where I am going wrong?

if (Ti.Platform.osname=='iphone') {
Ti.include('lib/oauth.js');
Ti.include('lib/sha1.js');
Ti.include('lib/birdhouse-debug.js');
}
// android will search the current directory for files
else {
Ti.include('oauth.js');
Ti.include('sha1.js');
Ti.include('birdhouse-debug.js');
}

var BH = new BirdHouse({
consumer_key: "",
consumer_secret: "",
callback_url: "http://www.employeechatter.com/callback"
});

BH.tweet("This is a test",function(){
Ti.UI.createAlertDialog({title:'Twitter', message:'You tweet has been posted'}).show();
});

@jpurcell
Copy link
Owner

Ok, well, if I understand your code correctly, then I think your code is incorrect. You will need in your app.js (or the window you are calling BirdHouse from) the following:

var BH = new BirdHouse({
consumer_key: "this",
consumer_secret: "that",
callback_url: "http://www.employeechatter.com/callback"
});

BH.tweet("This is a test",function(){
Ti.UI.createAlertDialog({title:'Twitter', message:'Your tweet has been posted'}).show();
});

Then in the birdhouse.js file you should have just:

if (Ti.Platform.osname=='iphone') {
Ti.include('lib/oauth.js');
Ti.include('lib/sha1.js');
}
// android will search the current directory for files
else {
Ti.include('oauth.js');
Ti.include('sha1.js');
}

With those changes, does it work now?

@AussieBattler
Copy link
Author

Hi. Thanks for taking the time to reply. I tried what you said but it still doesn't work. No idea what I am doing wrong. As I say the birdhouse demo works with the same credentials.

It appears to verify everything but then when I try to send the tweet it no longer has the login details.

Following is the debug screen information:
[INFO] ----- Opening Tweet UI -----
[INFO] ----- Initializing Authorization Sequence -----
[INFO] ----- Initializing API Request Sequence -----
[INFO] 1:
[INFO] 2:
[INFO] 3: Twitter / Authorize an application
[INFO] 4: http://api.twitter.com/oauth/authorize?oauth_token=Sf4BsJAOChscr9q2UtJUrTJFBA40lG1US3vz7Z9ko
[INFO] 1:
[INFO] 2: http://api.twitter.com/oauth/authorize?oauth_token=Sf4BsJAOChscr9q2UtJUrTJFBA40lG1US3vz7Z9ko
[INFO] 3: Twitter / Authorize an application
[INFO] 4: https://api.twitter.com/oauth/authorize
[INFO] ============== loads 2 ==============
[INFO] 1:
[INFO] 2:
[INFO] 3: 404 Not Found
[INFO] 4: http://www.employeechatter.com/callback?oauth_token=Sf4BsJAOChscr9q2UtJUrTJFBA40lG1US3vz7Z9ko&oauth_verifier=BpWYdygryfPrd4PZkt7dcYW1KQZkhYd1l2LHVF4MoQU
[INFO] ============== loads 3 ==============
[INFO] listen for tokens in url
[INFO] ----- Initializing API Request Sequence -----
[INFO] Authorization is complete. The callback fn is: undefined
[INFO] alright, we can tweet now: typeof undefined
[INFO] ----- Opening Tweet UI -----
[INFO] ----- Initializing Authorization Sequence -----
[INFO] ----- Initializing API Request Sequence -----
[INFO] ====================check status
[INFO] cancel check status bc we are doin our thing
[INFO] var_dump: error (object):Error Domain=ASIHTTPRequestErrorDomain Code=3 "Authentication needed" UserInfo=0x6a5a600 {NSLocalizedDescription=Authentication needed}
[INFO] Application has exited from Simulator

@jpurcell
Copy link
Owner

Ok, this looks like the exact same issue lunica is having on issue #4.

If you read the issue ticket, you'll see that I'm at a complete loss. The key issue is being able to reproduce the issue, and I cannot.

It's not that the script is "losing" the access token and token secret or anything, If you view the debug output (not just info), you'll see that your access token and token secret are being set and sent in the XHR call.

Do you have any thoughts on maybe how I could reproduce the error or perhaps its causes?

If it is working with the BirdHouse App, copy the BirdHouse files from it (including the oauth.js and sha1.js files) to the app you are making and see if that changes anything.

@AussieBattler
Copy link
Author

Hi. Sorry for delay in replying. I basically rebuilt my app from scratch and this time the code worked. I then deleted the birdhouse.js file as I was using the debug version and the error returned. I then replaced all the files with the original (including the deleted birdhouse.js file) and everything was working again. So I am not sure if this is a red herring but it looked like it had something to do with birdhouse.js file being also included and not missing.

Thanks for your assistance.

@jpurcell
Copy link
Owner

I'm relieved to hear that it is at least working. Yet, you still aren't able to get birdhouse.js working, yes?

@AussieBattler
Copy link
Author

Hi. Not exactly (and I stress this might be a red herring but it's what I did to fix it). I am only referring to the birdhouse_debug.js file in my app (which is fine) but if I remove the birdhouse.js file from the lib folder then this error occurs. If I put the birdhouse.js file back in the lib folder then everything works fine.

On 18 May 2011, at 13:34, jpurcell wrote:

I'm relieved to hear that it is at least working. Yet, you still aren't able to get birdhouse.js working, yes?

Reply to this email directly or view it on GitHub:
#6 (comment)

@jpurcell
Copy link
Owner

hmmm... can you perhaps post the error? If birdhouse.js is never included by your app then it should never throw an error (unless it's a compiling error).

@AussieBattler
Copy link
Author

It is the same error details I previously submitted.

I completely agree with your summation and it makes no sense to me. But I had the initial error, rebuilt the app and everything was working fine. I then deleted the birdhouse.js file (as I was happy to use the debug version) and the error returned. I copied the birdhouse.js file back and it was working again.

It doesn't make sense to me but I thought I'd share my findings with you.

Sent from my iPad

On 18 May 2011, at 17:37, [email protected] wrote:

hmmm... can you perhaps post the error? If birdhouse.js is never included by your app then it should never throw an error (unless it's a compiling error).

Reply to this email directly or view it on GitHub:
#6 (comment)

@jpurcell
Copy link
Owner

Alrighty then! Thanks for posting--be sure to let us know if you find anything else out. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants