Using Twitter API to embed tweets with URL - ruby-on-rails

I'm trying to embed tweets in my app by passing in a tweets URL. I'm completely inexperienced with APIs and need a bit of guidance to set it up. Twitter has some documentation here and here on how to do it using Oembed. The part I'm unclear on is how to make a request:
"Make a request to the following URL for each Tweet ID, where {tweet_id} represents the value changing in a programmatic loop:"
https://api.twitter.com/1.1/statuses/oembed.{format}
Also unsure on where to add the API keys Twitter gives me. Sorry for the broad question, very new at this.

Related

Can't access twitter profile URL - using STTwitter Wrapper

I'm using the STTwitter wrapper to connect with Twitter and I'm running AppOnly and I'm able to retrieve the tweet text with no problems. I'm using the getStatusesUserTimelineForUserID method for that.
The problem is that I can't access "twitter_profile_url" or "profile_banner_url" but I can access text and tweet time and tweet ID perfectly fine.
I did however manage to get the twitter_profile_url by using the getUsersShowForUserID method.
My question is that am I doing something wrong when trying to access twitter_profile_url with getStatusesUserTimelineForUserID? I looked over Twitter's documents and I think the reason why getUsersShowForUserID works is because of the includeEntities property. I'm not 100% sure on that so I was wondering if someone could clarify that for me?
The endpoint statuses/user_timeline.json returns a list of tweets.
Each of these tweets has a user dictionary, and this dictionary should have keys such as profile_image_url, profile_image_url_https, profile_banner_url, profile_background_image_url or profile_background_image_url_https.
So yes, it should be working, and if not then please open an issue on STTwitter project and post the exact code you're using.

Search YouTube API without login in

I'm creating an app where i would like to display video result from the YouTube site.
However, i do not want the user to register for this.
After i registered my app, and allowed "YouTube Data Api", Still when i'm calling from my app:
https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=3&order=relevance&q=test&regionCode=AR&type=video&key={MyKey}
I'm getting back "forbidden (403)"
This issue suppose to be really simple, but i'm really straggling to get this to work, i'm thinking maybe it has something to do with the new API version 3.0, that you can not search without authentication?
Any help would be much appreciated thanks.
You can use below URL for searching of youtube videos using version3
https://www.googleapis.com/youtube/v3/search?part=snippet&q=nokialumia&key=#"API _KEY"&maxResults=20&pageToken=0
For suggestions of you tube videos you can use below link. It will gives you the data in XML format. You can parse and get results.
http://suggestqueries.google.com/complete/search?output=toolbar&ds=yt&q=nokialumia
If you want to use Version 2 use below link
Youtube Search using version 2.0
Hope it helps you...!
What kind of results do you want to see? Views, comments, share, likes? I think that you are not able to see any results by Youtube Data Api or Youtube Analytics API V3 without a valid key. You can find all error codes and their meanings from this link.
I hope it helps.

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.

Searching Twitter feeds

I'm looking to take information from Twitter feeds such as removed posts. Is it possible to do this through some sort of string match search by looking for keywords, that is, "this post removed"?
This is for an Arduino project.
It should be. Twitter just turned off their old API, though, so as long as you're willing to get an API key, you should be fine (https://dev.twitter.com). Grab the data with loadBytes or loadStrings called on the API URL and then start walking through the data you got back (http://processing.org/reference/loadStrings_.htm) -- which in the new API will be JSON. You can use a JSON library to turn that into an actual object, but frankly if you want to do text matching, which you do, then there's really no need for Object repacking.

How do I know if a specific twitter user is online or not?

How do I know if a specific twitter user is currently online by writing programs? Is there any API or data field in the web page showing this information? Both browsing Twitter webpage and using Twitter app are considered "online".
Although this information is not readily available, you can do a work around. Make use of Twitter's Streaming API: https://dev.twitter.com/docs/streaming-apis/streams/public (have a read through this document).
You'll most likely be using the POST Statuses/filter functionality (read the doc here: https://dev.twitter.com/docs/api/1/post/statuses/filter ), which will give you a JSON object with tweets based on your filters.
Make use of the parameters you'll need to specify in the URL to filter the stream (have a look through this document to learn more about it: https://dev.twitter.com/docs/streaming-apis/parameters ), in your case it'll be the follow parameter. You basically specify the twitter ID of the user you want to follow. Here's a sample JSON result of the streaming API in action https://stream.twitter.com/1/statuses/filter.json?follow=25365536 - this one in particular is following Kim Kardashian. Keep in mind that this will give you:
Tweets created by the user.
Tweets which are retweeted by the user.
Replies to any Tweet created by the user.
Retweets of any Tweet created by the user.
So in order to just stream the tweets of your desired user, you'll have to use a programming language of your choice to parse through the JSON object to find the user that actually sent the tweet (this is a little tricky, you'll have to look through the properties of the JSON object to figure it out). Once you narrow the streaming tweets to just the ones from the user though, you can then have an alert on when new tweets by this user stream and that will tell you if the user is online/using twitter at the moment.
It's not clear what you mean by "online" (browsing twitter.com? Using a Twitter app?), but in any case Twitter doesn't provide such information, thankfully.
I'm afraid such information is limited by Twitter and is not available. However you can put your question on https://dev.twitter.com/discussions and ask its developers. Good Luck
you need get user state first
then filter if around current time
then get ids
they are online
use twitter developer api
I do it for my website

Resources