Hi all,
I'm having some trouble using the TipJoy payment API; perfect time to
bounce what's happening off you all.
I'm sending an XmlHttpRequest in javascript. When I send the POST data
to my own server, extract the twitter_username and twitter_password
parameters, and make a call directly to twitter to update my status,
it works fine.
When I send the same POST to TipJoy, it returns a result failed
response, with the reason being "invalid twitter password".
Below is some information to help someone else reproduce or inspect
where things are going wrong:
Javascript:
I'm calling this from a firefox extension which reproduces much of
greasemonkey's functionality. I'm using the GM_xmlhttpRequest method
documented here
http://diveintogreasemonkey.org/api/gm_xmlhttprequest.html
code:
var send_to_url = '
http://localhost:8000/Main/test/xmlhttprequest/';
//var send_to_url = '
http://tipjoy.com/api/tweetpayment/';
//var text = 'p 1¢ @cwallardo testing';
var text = 'p something to cwallardo test';
var params = 'twitter_username='+escape('someusername')
+'&twitter_password='+escape('somepassword')+'&text='+escape(text);
GM_xmlhttpRequest({
method: 'POST',
url: send_to_url,
data:
'twitter_username=someusername&twitter_password=somepassword',
headers: {
"User-agent": "Mozilla/4.0 (compatible) Greasemonkey",
"Accept": "application/atom+xml,application/xml,text/xml",
"Content-type": "application/x-www-form-urlencoded",
"Content-length": params.length
},
onload: function(r) {
GM_log('xmlhttpRequest worked '+r.status+' '+r.responseText);
},
onerror: function(r) {
GM_log('xmlhttpRequest failed');
}
});
I'm running FF3 on MacOsX.
What I'm doing on my server, in case it is happening to bypass some
fatal flaw in my javascript, is:
1. handle request in Django
2. make twitter call using python twitter.py wrapper
Api(request.POST['twitter_username'], request.POST
['twitter_password']).PostUpdate('hello world')
I'm still learning javascript/ajax, so if you advice for encoding
(escaping?) javascript POST data, especially the cent symbol, I'd be
happy to hear it :-)
Thanks,
Lucy.