get tweets using stream API twitter using 1.1 - twitter

I found that we can use stream API to get the latest tweets based on hash tags or keywords.
It says you have to keep your http connection open. I am having a doubt regarding this.
Can anyone give me an example of stream API in php?
And other thing can I skip hashtag and keyword parameter is this API ? So I can all the statuses?
Can I pass a parameter like latitude and longitude to get tweets from the specific region?

You can request tweets by location, see their API documentation for specifying location boundaries:
https://dev.twitter.com/docs/streaming-apis/parameters#locations

Related

How to fetch Youtube public channel stats without authentication

I am trying to fetch metrics like views, likes, dislikes for videos in some popular public Youtube channels and also subscription information of the Channelsa on a daily basis. Also, country wise stats and gender wise stats for the channels required. But, Youtube Reporting API always prompts authentication. Is there any way to fetch those metrics for public Youtube channels without user authentication?(https://www.googleapis.com/youtube/analytics/v1/reports - need to use this API). Your suggestions will be very helpful.
For some of read-only requests you can just use access token without need to authorize. Check the documentation. Each request's documentation tells if authorization is needed.
The API you linked to is part of the "YouTube Analytics and Reporting APIs", which is split up in these very two pieces - analytics and reporting. I don't see why you need to use this exact API, but I can tell you that you won't succeed with it. This API is intended for channel owners and network owners to get information about their own channels. You absolutely have to authenticate via OAuth in order to use it, there is no way around this.
In order to get video and channel metrics, you can consult the YouTube Data API. Here, an API key from the Google Cloud Console will let you fetch any public data without further authentication. But it will not provide you with data records in specific periods of time, it always returns the current values of the requested properties.
In other words: what you are asking is, as far as I know, impossible to achieve with any official YouTube API.
A workaround for your problem would be to fetch the desired properties via the Data API on a, say, daily basis and compare their values to the previous day's values and calculate the delta.

Get tweets for a specific user V1.1

I'm not really sure where to begin with this.
Prior to the upgrade to version 1.1 of the API I was able to request tweets in XML format using
$url = 'http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=' . $TWITTER_USERNAME;
A couple of things have changed, the return format is now JSON which isn't a problem but I'm not sure how to authenticate my app to request the tweets in JSON format.
I've read this link but am unsure how I'm supposed to implement it.
For instance, where do I get the consumer secret from ?
How do I request a bearer token in PHP ?
Any pointers would be great
you need to use plugin that is written for v1.1, In new version they have added security layer so you need to be authorized in order to get the tweets via API, here are the links that will be helpful for you
http://www.webdevdoor.com/php/authenticating-twitter-feed-timeline-oauth/ http://www.fullondesign.co.uk/coding/2516-how-use-twitter-oauth-1-1-javascriptjquery.htm

Total Friend Count in Twitter API 1.1 version

Is there a Twitter API version 1.1 call that would provide the total number of friends a user is following?
The GET Friends/ids is the closest I found, however, it provides a list of all a user friend ids, not a total amount.
https://api.twitter.com/1.1/friends/ids.json?cursor=-1&screen_name=twitterapi&count=5000
Yes. If you use the users/show endpoint of the v1.1 API you can retrieve information about a particular user.
One of the fields that is returned is called friends_count - this is the value you are looking for.
Full details here: https://dev.twitter.com/docs/api/1.1/get/users/show
The answer above is the right answer and if you want to try a better way you can use as follows:
this is twarc library for python that is helpful for hydrating ids from tweeter API.
twarc is a command line tool and Python library for archiving Twitter JSON data. Each tweet is represented as a JSON object that is exactly what was returned from the Twitter API.
for using this library in python you can simply write the code below in a python file.
from twarc import Twarc
t = Twarc(consumer_key, consumer_secret, access_token,access_token_secret)
for tweet in t.hydrate(open('ids.txt')):
print(tweet["text"])
the consumer_key, consumer_secret, access_token, access_token_secret comes from (https://developer.twitter.com/apps) in your tweeter developer account.
This is for bulk user-ids that saved in ids.txt file that separated by enter ("\n")

How to get channel related data from youtube api

I need to get the video/playlists/show data from youtube.com.
Example :
http://www.youtube.com/channel/SWMb9NxQL9I6c
http://www.youtube.com/show/mtvroadies9/featured
Is there a way I can get the video details for the above URL using the youtube API?
Yes, using:
https://developers.google.com/youtube/v3/docs/channels
e.g.
https://www.googleapis.com/youtube/v3/channels?part=snippet&id=SWMb9NxQL9I6c&key={YOUR_API_KEY}
You need to look at the YouTube Data API. You will find there documentation about how the API can be accessed. You can also find client libraries.
You could also make the requests yourself. Here is an example URL that retrieves the latest videos from a channel :
https://www.googleapis.com/youtube/v3/search?key={your_key_here}&channelId={channel_id_here}&part=snippet,id&order=date&maxResults=20"

Twitter Streaming API - filtering by urls

I am trying to filter tweets from the Streaming API using a url in the track parameter. However I'm not getting the tweets I expect. My suspicion is that the filter doesn't apply to the expanded url and but to the automatically shortened url (t.co).
Can anyone confirm that this is the case? The Streaming Api docs don't even mention how the filtering is applied.
If this is the case does anyone have a workaround?
I'm using the extended URL with cURL. I get the live tweets on my terminal for a particular search parameter. You may like to look into this one.
curl https://stream.twitter.com/1/statuses/filter.json?track=SEARCH_PARAMETER -uUSERNAME:PASSWORD

Resources