Getting Status 401 Error 32 only on favorites/create


#1

I’m able to post tweets, get user_timelines and retweet but when I try to favorite a post I get error 32. I’ve even taken my function for tweeting, changed the url and passed in the id to make sure it wasn’t a copy/paste error.

URL : "https://api.twitter.com/1.1/favorites/create.json"
id: '461141654033141760’
method: “POST”

What am I doing wrong?


#2

I’ve just used the OAuth tool on [node:10607] to favourite that same tweet myself via curl, so I’m curious as to what you’re doing in code? Are you using a client library? I’m also able to do it using twurl:

twurl /1.1/favorites/create.json -d "id=461141654033141760"
twurl /1.1/favorites/destroy.json -d “id=461141654033141760”

I suspect you may not be authenticating correctly?


#3

I’m using a library called social_plus for Titanium. Like I said, simply switching the url in a function that does authenticate properly doesn’t fix it. Here’s the whole function.

this.favorite = function(options) {
Ti.API.info(options.params.id);
var pUrl = “https://api.twitter.com/1.1/favorites/create.json”;
var pTitle = options.title;
var pSuccessMessage = options.onSuccess, pErrorMessage = options.onError;
if (accessToken == null || accessTokenSecret == null) {
Ti.API.debug(“The send status cannot be processed as the client doesn’t have an access token. Authorize before trying to send.”);
return;
}
accessor.tokenSecret = accessTokenSecret;
var message = createMessage(pUrl, “POST”);

	message.parameters.push(["oauth_token", accessToken]);
	message.parameters.push(["oauth_timestamp", OAuth.timestamp()]);
	message.parameters.push(["oauth_nonce", OAuth.nonce(42)]);
	message.parameters.push(["oauth_version", "1.0"]);

	OAuth.SignatureMethod.sign(message, accessor);
	var parameterMap = OAuth.getParameterMap(message.parameters);
	client = Ti.Network.createHTTPClient({
		onload : function() {
			if (client.status == 200) {
				pSuccessMessage && pSuccessMessage(this.responseText);
			} else {
				pErrorMessage && pErrorMessage(this.responseText);
			}
		},
		onerror : function() {
			Ti.API.error("Social.js: FAILED to send a request!");
			Ti.API.error(this.responseText);
			pErrorMessage && pErrorMessage(this.responseText);
		}
	});
	client.open("POST", pUrl);

	header = OAuth.getAuthorizationHeader("", message.parameters);
	client.setRequestHeader("Authorization", header);
	if (!Ti.Android) {
		client.setRequestHeader("Content-Type", "multipart/form-data");
	}
	client.send(options.params); 

#4

I’ve edited my main post with the function call.


#5

Can anyone help? Again it’s ONLY when I try to favourite. I can get my timeline, other peoples timelines, post and retweet, but not favorite. Is there anything special about this function I’m unaware of?


#6

So error 32 indicates “could not authenticate you” (https://dev.twitter.com/docs/error-codes-responses) but that’s weird, since obviously other authenticated methods are working for you.

I’m afraid I haven’t used Titanium before but I’m familiar with what it is. Looking at the code above, if simply hitting a different endpoint to favorites/create.json works, I’m not entirely sure what the issue is. Are you able to trace out the HTTP call that is being made so we can compare it against what twurl does?


#7

Not as far as I’m aware, but some things of note:
If I don’t send the id field, I get error 38 telling me I need that field, but if I send id = 0 I still get error 32 instead of error 34 page not found.


#8

Does anyone know of ways of getting a more helpful error message than this? Or something I can do to find the source of my problems?


#9

Anybody?