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);