Closed sureshthandapani closed 9 years ago
Hi @sureshthandapani. The OAuth Proxy merely serves to sign OAuth1 requests, it does not have any proprietary logic of which you speak, that is all defined in the modules/*.js file which you have rightly edited.
The role of p.data = null;
is to prevent the POST BODY from being generated, the post data is instead within the request path. As per instructions given by twitter API https://dev.twitter.com/docs/api/1.1/post/statuses/retweet/%3Aid
Uploading an image to Twitter is currently not supported. I would be very interested in propositions to include this feature in HelloJS
A few months ago I worked on adding support for photo uploads on both Twitter and Facebook modules.
While working on the Twitter module I found out the node-oauth-shim proxy discarded, dismissed or simply did not take into account headers for POST requests created client-side. Without proper headers Twitter's API would simply reject all my POST requests.
Here's my addition to the node-oauth-shim/proxy.js file to proxy headers for POST requests: https://github.com/tangible/node-oauth-shim/commit/8785d9f3561362b2da20d6f15c2d8e59ed982b58
And my rushed but working addition to the Twitter module: https://github.com/tangible/hello.js/commit/2b10cec1fad17d09f85b5563de81b2cfcf778e09
I used https://github.com/twitter/twurl as reference to understand and properly build headers as expected by Twitter's API.
Feel free to take anything from there you might find valuable or useful to your project.
@reynaldot thats a great contribution, thankyou. Make them PR so you get recognition.
@reynaldot thats a great work, thanks alot.
@MrSwitch, @sureshthandapani I will set aside time next week to make a PR for this feature.
Hi everyone, what's the status on this issue? I seem to not be able to get POST request (for retweet) working. I get this error:
{
code: 34,
message: "Sorry, that page does not exist"
}
Is this related to this issue? I'm calling hello.api
like this:
return hello.api('/twitter/statuses/retweet/' + tweet.id + '.json', 'post', {
id: tweet.id
})
Thanks a lot for any hints you can give.
Did you read the response error? The resource path you are using is incorrect. Try this one instead:
twitter/statuses/retweets/:id
@reynaldot That doesn't work for me. Rather, I'm getting a TypeError. This is how I made it work:
hello.api('/twitter/statuses/retweet/'+tweet.id_str+'.json', 'post')
Is is supposed to work with URL parameters like :id
? If so, this could be a bug, but I haven't seen this pattern anywhere in the docs.
I have an error also using the demo at http://adodson.com/hello.js/#helloapi - the chrome (64bits on ubuntu) console displays this error:
Uncaught TypeError: Cannot use 'in' operator to search for 'nodeName' in null hello.all.js:2136hello.utils.extend.clone hello.all.js:2136getPath hello.all.js:1919hello.init.twitter.post.me/share hello.all.js:5006processPath hello.all.js:2047hello.api hello.all.js:1867hello.api hello.all.js:2797(anonymous function) hello.all.js:3009action index.js:826Test.run index.js:842(anonymous function)
@raffaeleguidi thanks for pointing that out, i had just caused that, now resolved in v.1.2.1
+1. I got @reynaldot's patches working rebased against the newest hello.js and auth-server a few days ago. Pull requests to make it easy (and an update to auth-server.herokuapp.com) would be fantastic.
@davidpfahler my bad for misleading you. The path you have been using is correct. I didn't notice you were POSTing to the API.
You asked:
Is is supposed to work with URL parameters like :id?
I don't think so. I was just referencing the path to the endpoint as described on Twitter's API docs.
Merged in @reynaldot Twitter POST media feature, please check it out 9ea53048add its on http://adodson.com/hello.js/tests/#hello-x-api-path--method--data--callback--
it works just fine :)
https://twitter.com/raffaeleguidi/status/517041304757612544
2014-09-30 15:40 GMT+02:00 Andrew Dodson notifications@github.com:
Merged in @reynaldot https://github.com/reynaldot Twitter POST media feature, please check it out 9ea5304 https://github.com/MrSwitch/hello.js/commit/9ea53048addcf649457151a8c1e894f4c3bf54d2 its on http://adodson.com/hello.js/tests/#hello-x-api-path--method--data--callback--
— Reply to this email directly or view it on GitHub https://github.com/MrSwitch/hello.js/issues/72#issuecomment-57314760.
@reynaldot I got it all working now with hello.api('/twitter/statuses/retweet/'+tweet.id_str+'.json', 'post')
Added retweet, see f07dbc7c125ba8629d819ba69615b34b6112fb88
usage e.g.
hello('twitter').api('me/share', 'post', {id: 1234567}).then(handler);
Also I have been considering a generic endpoint, synonymous for github's "stars", facebook's "likes". like and twitters "favorites". e.g.
hello('twitter').api('me/like', 'post', {id: 1234567}).then(handler);
Hey guys, interesting stuff going on! I've a little problem.
I'm using hello js to call an authenticated user's mentions (the last 200), and I want the user to be able to favourite/retweet each mention if they wish.
I'm currently using the 'me/like' & 'me/share' endpoints and it's working fine. What I'm doing is:
I get a user's mentions, loop through them and then display them with a retweet & favourite button. For each mention, I take it's id string and push it into a new array. Then I loop through the array and pass it into the {id : mention_id_str[i]} part. Here's my code:
hello('twitter').api('https://api.twitter.com/1.1/statuses/mentions_timeline.json?screen_name=' + screenName + '&contributor_details=true&count=200').then( function(response){
console.log(response);
// Count Properties
function countProperties(obj) {
var count = 0;
for (var prop in obj) {
if (obj.hasOwnProperty(prop))++count;
}
return count;
}
var numOfObjects = countProperties(response);
var mentiondIDs = [];
var mentionArray = response;
var mentionArrayLength = response.length;
for (i = 0; i <= numOfObjects; i++){
mentiondIDs.push(response[i].id_str);
console.log(mentiondIDs);
var mentionedBy = response[i].user.name;
var mentionedByScreenName = response[i].user.screen_name;
var mentionedTweet = response[i].text;
var mentionedByPhoto = response[i].user.profile_image_url;
var timeCreated = response[i].created_at;
var mentionID = mentiondIDs[i - 1];
var favourite = response[i].favorited;
// insert mentions in list
var mentionsElement = document.getElementById('twitterMentions');
mentionsElement.innerHTML += "<li class='table-view-cell'><img id='twitterMentionPhoto' src='" + mentionedByPhoto + "'><p id='userTwitter'>" + mentionedBy + "</p><p id='usernameTwitter'>@" + mentionedByScreenName + "</p></br><p id='tweet'>" + mentionedTweet + "</p><span id='retweet' class='icon oi' data-glyph='loop'></span><span id='star' class='icon oi' data-glyph='star' ></span><span id='respond' class='icon oi' data-glyph='share' ></span></li>";
document.getElementById('retweet').onclick = function retweet(){hello('twitter').api('me/share', 'post', {id: mentionID}).then(function(success){console.log(success);})};
document.getElementById('star').onclick = function star(){hello('twitter').api('me/like', 'post', {id: mentionID}).then(function(success){console.log(success);})};
}
});
Any solutions to how to do this properly? Really stuck. Thanks a lot
inactive
Hi Andrew,
I want to implement Twitter functionalities (i.e. post the image content, favorites, retweets). I have done these functional code, but its not working. It through error message
{"errors":[{"message":"Bad Authentication data","code":215}]}
. I think the problem with these functional code was not implemented in OAuth Proxy server or else problem with my code. Below I have added my code snippet.Please help me to solve this issue.