Twitter tweets about a certain url via salmon and/or pubsubhubbub? - twitter

For a web-application I am writing (Rails) I am looking for ways to post back publick mentions about that post. Mentions on Twitter, Facebook, Reddit and so on.
Starting with Twitter, I am looking for a way to get these tweets back into the application. Obviously I could simply monitor the twitter firehose (through their search, most probably) for a certain url (the url of the post), if found, extract that and place that tweet as new comment to the post. But this requires me to invent something similar for each and every social network.
Whereas there is a generic protocol for this: Salmon, allowing services to push such comments (tweets mentioning your url) through PubSubHubbub (PSH).
I did not find any mention of this on the Twitter API itself; they are not using PSH or Salmon (yet) it seems.
But maybe there are thirdpartis that do? Know any? Are there other projects that wrap around Twitters firehose and allow you to approach Twitter as if it is a Salmon-speaking pubsubhubbub? And What about Reddit, or Facebook?

The Twitter API TOS explicitly forbids the re-distribution of tweets via APIs*, except for Twitter's partners. These are DataSift and Gnip - but they don't do what you are looking for.
Your best option would be to simply monitor the filterhose.
* Actually, it's allowed to share IDs, but those are pretty useless since you have to look them up manually.

Related

Searching through a Twitter feed for an Alexa Skill

I'm working on a fairly basic Alexa skill that, in essence, searches through a specific Twitter feed looking for a hashtag, parses that tweet, and reads it back. What's the simplest way to pull data from a Twitter feed? I've been having issues working with the Twitter API (see below) and scraping data from Twitter appears to be against the TOS.
... crawling the Services is permissible if done in accordance with the provisions of the robots.txt file, however, scraping the Services without the prior consent of Twitter is expressly prohibited.
To write an Alexa skill
Follow a tutorial.
Simple enough. Use a pretty interface to add an invocation, some intents, and a slot type with the data I want.
Write an AWS Lambda function to handle everything.
Python because I know it better than JavaScript. Pick one of the Python wrappers for the Twitter API, then realize that because Twitter, all of their API requires authentication - even basic searches.
Register an app with Twitter so I have keys and tokens.
Realize having authentication keys and tokens in plaintext in an application is a bad idea, and decide to figure out account linking for Alexa.
Try following the one tutorial around, twice. Have trouble and go to StackExchange.
Why the need for an external webapp?
...we need an OAuth implementation of our own to make the integration work correctly
What's wrong with the one provided by Twitter? Why can't any issues be fixed within the Lambda method, since the account integration isn't being touched otherwise AFAIK? Isn't having the tokens passed around via the URL a bad idea too? Their example code seems to require that the Consumer Secret be hard coded too.
Enter: “https://alexa-twitter-airport-info.herokuapp.com/oauth/request_token?vendor_id=XXXXXX&consumer_key=YYYYYY&consumer_secret=ZZZZZZ”.
At the very least, their webapp seems to be down for the time being, and it'd be nice to have an option that doesn't require paying money to host another copy.
I've seen this post discussing a Node.js OAuth implementation, but the necessity for such an implementation still escapes me.
I found twitter Node package useful doing this. I used search/tweets GET API for my purpose which is shown below. However you have various APIs which are available to work with the tweets. The code below only shows the parts needed to access Twitter API from within Node JS.
var Twitter = require('twitter');
var client = new Twitter({
// I added the keys as AWS Environment variables
consumer_key: process.env.consumer_key,
consumer_secret: process.env.consumer_secret,
access_token_key: process.env.access_token_key,
access_token_secret: process.env.access_token_secret
});
client.get('search/tweets', {q: <<your search query>>,count:<<if you want to receive specific number of tweets>>}, function(error, tweets, response) {
var noOfTweets = tweets.statuses.length;
if(error) {
speechOutput = "I could not find tweets for <<your reason>>"
self.emit(':tell', speechOutput);
} else if(noOfTweets === 0) {
speechOutput = "another speech output";
self.emit(':tell', speechOutput);
} else {
tweets.statuses.forEach(function(tweet) {
//process the tweet the way you want to.
});
}
});

How to use Twitter User Streams

I am new in Twitter API. I have a requirement like I have to pull the information of an authenticated twitter user to know the number of followers. I can do this using REST API but I have a problem here. So I have taken the way to use Twitter User Streams.
I am not able to integrate this functionality in the site. I am using twitter console( https://dev.twitter.com/console ). But there I am not able to get any kind of result, it actually hangs/shows gateway timeout. And that's for I am not able to configure that how to write the code for this or how to use this in site. I am not passing any kind of parameters.
So, any body can please help in this would be very grateful( a clean sample code for this or any link where to get the good documentation ). I have already checked with twitter dev documentations.
Thanks in advance :)

How to get results with twitter search api?

I wish to get tweets with a keyword. But There is no result with any keyword.
http://search.twitter.com/search.json?q=summer
How to get results with Twitter Search API?
Version 1 of the twitter API has been deprecated and is being removed. Not sure how you can miss the giant warnings on the twitter dev site ;) This means simple code like the above will not work any more.
So, you now need to make authenticated requests (OAuth) using the 1.1 API, and it's nowhere near as simple as just doing a (in PHP) file_get_contents(http://search.twitter.com/ ...).
I couldn't see any server-side languages you use from your profile, but I wrote a lengthy post explaining the issue (with pictures) and how to use a php library to perform authenticated requests.

BlackBerry 10 Twitter Integration

I would like to integrate Twitter into my BlackBerry 10 application so that I can post, get, favorite and retweet messages from Twitter. Native BlackBerry.
Try searching on github - there are several sample twitter projects on there:
Github search results
For example: BB10 Sample Twitter App
At the moment, BB10 platform offers built-in invocation requests for a core Twitter app, however, these requests are pretty limited in functionality - you can only share content with different URI, but not get, favourite, retweet message and so on.
If there's another application which can handle these type of requests, you may use unbound (or bound) requests for you needs, but in order to do that you have to know Action attribute (and TargetID in case of bound invocations) value.
Here is a link explaining mechanism of invocation sending as well as bound and unbound requests - https://developer.blackberry.com/cascades/documentation/device_platform/invocation/sending_invocation.html

How to deal with Twitter API Limits?

I have this project that's based on a Twitter Bot. NOT an abusive or spammer bot. Just a robot that will reply with information about my system when it's mentioned.
The thing is: I expect to have about 3000 mentions/hour. Which means I have to send about 3000 replies/hour.
I know Twitter API calls are limited to 350/h when the app is authenticated and 150/h when it's not. But I've also read about it being 1000/h somewhere in the Twitter Discussion boards.
Anyway, how can I deal with having to send so many replies/hour?
I thought about creating multiple Twitter accounts and delegating some of the replies to them in order to being able to reply to all of them, but I do realize it's not a pretty solution.
Does anyone have a better idea?
Your best bet is to use Streaming.
Connecting
API Params (JSON)
Basically, you open up a connection with their server with your credentials and instead of reading the return stream and closing, you just keep reading. When you want to make a request, you just send another header or something.

Resources