Get Instagram media with a specific tag in specific time period - ruby-on-rails

I am in a situation where I need to get all the photos posted to instagram with a particular tag in a specific time period. Basically, I want to show all the images those were posted in between certain time period (Probably dates). But as of now I can't see any option that is being provided in the instagram tags api.
I have tried using the same api to get the photos and loop through it with a condition to check the created_time. But I found that the response is not ordered by created_time. Is there any way I can achieve the same, Any help would be appreciated.

Currently there is no option to do this. Other APIs have max_timestamp and min_timestamp options, but tag media endpoint does not have this option.

Related

Using YouTube API, is it possible to filter search by upload date?

I'm working on a personal project to retrieve YouTube videos on a particular subject very quickly after they are posted. Using the "Sort By" filter works well, however, I've noticed that some videos that fit the search query do not appear in the HTML. So, I was wondering if it is possible to also sort by Upload date, similar to the YouTube feature which allows for filtering videos based on if they were posted in the last hour, today, this week, etc. I believe that if I could include a filter for videos posted in the last hour, that would improve the accuracy of my project.
Any help is very much appreciated.
Check out the "order" parameter in this API (can set it to "date").

How to find out if a user has actually Tweeted?

I have a website which allows the user to tweet using a specific hashtag, would their be anyway to actually find out if the user has really tweeted.
I was thinking of looking at the timestamps and just working out the difference between right now and when the last tweet was made but that's not really professional.
I know Facebook allows you to do this quite easily but I'm struggling to figure out the best solution.
any ideas?
Regards
Retrieve the tweets of the user in question
Scan the text of each tweet, looking for your hashtag.
If you know when they visited your website, compare the time of the visit to the time of the tweet.
If you need to ensure the users tweets, then tweet for the user by requesting authorization and then tweeting via the API. This will still not stop the users from deleting the tweet.
If you plan any reward scheme, you won't be able to force users to keep the tweet (and probably the twitter API ToS forbid such things).
You want to use the Twitter STREAM API. One of the public stream is the Filter Stream.
This stream give the possibility to specify keywords/hashtags that you want to follow in live.
You can simply track the hashtag that you want and then you will receive in live all the tweets posted with your hashtag.
You can then simply check the json property user and compare the id/screen_name to the user you want to identify.

Twitter Search Tweets API - Different Users But Returns Same Tweets

I'm trying to create images streams from social media hashtag.
When i try to using Twitter, there's a problem when getting tweets images. I already succeed displaying the images but there's a lot of duplicate tweets! The reason is there's a few users who tweet same tweet, and i think they all are bot because when i stalk their profile they all got same tweets.
Here is the example :
http://t.co/NMX3B68eBT http://t.co/xDeBSS7GRr http://t.co/VmmNezY8Qg
Here is the query :
$response = $twitter->get('search/tweets.json?q=%23holifestival -filter:retweets filter:media&count=20');
How do i fix the duplicate tweets like this? is it possible?
if it's isn't, is there any workaround? please help me.
thanks
You really only have two options.
Compare the text (ignore the URL) and see if it matches a previous tweet. If it does; discard it.
Compare the images. After downloading the image, compare it to other images you've downloaded (either filesize or MD5 hash). If it matches, discard it.
One of Twitter's problems is that multiple spam accounts can be used to repeatedly broadcast identical content. Other than examining the content, there's no way in the API to filter it.

How should I get all the tweets of an specific hashtag?

I'm trying to develop some code in order to get all the tweets that were generated with certain hashtags, then parse them and finally analyse them. I believe I've already thought and solve the last two parts of this but I'm having some trouble with the first one. I've already read the Twitter Search API documentation but I haven't realised yet how to do this. Can anyone help me?
If you want to retrieve the tweets sent recently, you should use the search/tweets endpoint of twitter' REST API, and mention the hashtag inside q parameter
In case you want to listen to tweets containing the hashtag and receive them in real time, then twitter's streaming API is what you should use (statuses/filter endPoint).
Have a look at the documentation on twitter's website, there's also plenty of information on how to do this all around the web.

Find the number of times a tweet has been viewed

There have been quite a few number of start-up pertaining to analyzing Twitter data. There is CrowdBooster, then there is Klout, which use Twitter data to tell the user their True reach.
I have got the following two questions:
1) Is there a way to find out who has viewed one's tweet, or the number of people that have viewed a tweet. Crowdbooster claims to tell you how many impression one received per tweet. How do they do it?
2) Thousands and thousands of links are shared each day on Twitter. Can we find out which user has clicked the link in a tweet?
I have looked through Twitter API and some of the companies that have licensed Twitter's Firehose, but have not found anything that meet my needs.
Also, to give you a short answer to your 2nd question. Now that we've established that view analysis is impossible. Can you find out which user has clicked on that link, absolutely. And depending on what your talking about, user as far as the user who has clicked on the link or the user that has the link on their Twitter stream. Both are possible,
in the case of A, you would get the referring users IP address. Methods vary depending on language.
But what I think your asking for is scenario B, finding out which user has the link in their Twitter stream. This can be done by querying the link, the API response you will get can include tweet entities which will list all this information out for you and more. Open up a firehose with your link and watch what comes in.
https://dev.twitter.com/docs/streaming-api/methods
1) Is there a way to find out who has viewed one's tweet, or the
number of people that have viewed a tweet. Crowdbooster claims to tell
you how many impression one received per tweet. How do they do it?
No, in the case of a view - this would be impossible. The tweet impression can happen in multiple silos. On the website, in a widget, in a mobile app. You can imagine that it's simply not possible to get the impression of a tweet on a view because of this reason and because unlike a click, there is no I viewed this tweet identifier sent when a view has been enacted. I spent a great deal of time researching for a way to get the tweet impression even based on a similar clicked link and this is not even possible. (edit: it's possible see the last paragraph) This brings us to question 2.
2) Thousands and thousands of links are shared each day on Twitter.
Can we find out which user has clicked the link in a tweet?
Yes, what these websites are mainly doing is analyzing links that you process through their website. If you can have a unique hash marker on a link then analysis becomes possible. Without a unique hash marker, Twitter will re-interrupt two of the same links in a exactly the same way, even in the case that it shortens your link to it's custom t.co wrapper.
This means the only reliable way to do tweet analysis is by including a unique link marker code on your tweet and analyze the the fact that somebody that has hit your server has clicked on that link.
There is a somewhat hidden Twitter API feature that helps you understand how popular a particular link is. That being the link count API .. http://urls.api.twitter.com/1/urls/count.json?url=
Something really outside of the box you can do if your set on analyzing multiple versions of exactly the same link without using markers and if your also using the Streaming (firehose) would be to analyze the tweet views (using the link count API) on similar links that hit your server. The link that got the +1 boost in view is the one that hit your server. But that's about the extent of creative analysis you can get with your tweets and more specifically the links, as mentioned links are the only thing your really able to analyze when it comes to Twitter.
1) Is there a way to find out who has viewed one's tweet, or the number of people that have viewed a tweet. Crowdbooster claims to tell you how many impression one received per tweet. How do they do it?
Yes, sign up for Twitter Analytics https://analytics.twitter.com (free service provided by Twitter) and you can see how many people view (impressions) for each tweet and totals for specific dates or a date range.
2) Thousands and thousands of links are shared each day on Twitter. Can we find out which user has clicked the link in a tweet?
Yes, you can do this. Using a URL shortening service like Bitly.com you can track how many clicks you had from Twitter (only give out that Bitly link on Twitter to do this). But if you want more indept information you may need to create a tracking software, as I don't know of any available. To do that you would need the tracking software to track the link and find out the refer header and see if it's from Twitter (or better yet, just give out a unique URL for your tweets), then you would need to use the Twitter API to find out the handle (username) of that visitor who clicked your link. Lastly store this information in a database so you can review who clicked what link.

Resources