How to search Twitter? - php

I need a PHP script that uses the Twitter API to obtain the following information: the number of unique tweets (or status updates) from a specific user (using their twitter username) containing a specific hashtag during a specific period of time.
I need that value to be the only returned data from calling that function/script; as well as the customizable lines of code containing all relevant values that I need to fill (app id, secret, username to obtain info from, etc).

Zend Framework has a nice Twitter API lib, which can be used standalone:
http://framework.zend.com/manual/en/zend.service.twitter.html

This is very simple to do with Twitter's Search API.
This is a JSON feed (just fetch with cURL or file_get_contents() and parse with json_decode()) of my Twitter posts that include the #fb hashtag: http://search.twitter.com/search.json?q=+%23fb+from%3Aceejayoz

Related

Is there on Instagram an official way to get photos according to hashtag but from ALL users and not only from the one related to the client id?

I know it's super easy to retrieve photos from Instagram according to a specific hashtag from your own profile (with the client id used in the connection to the library), but I could not find anything official to retrieve photos with an hashtag, independently by the users.
So, for instance, if my hashtag was test, an API grabbing a PHP object containing photos as in this link as in the following code
$o_instagram = new Instagram($s_client_id);
$o_media = $o_instagram->searchTags($s_hashtag);
Any ideas or suggestions? Thanks in advance.
have a look at the following endpoint
https://instagram.com/developer/endpoints/tags/#get_tags_media_recent
I'm not sure how it looks in their php library but in ruby is is something along the lines of Instagram_client.tag_recent_media(:tag)
It's paginated in order of most recent first

Monitor retweets with PHP

I have a website Foo.com that creates a tweet for the user #FooWebsite.
Users on the website can retweet it and users directly on Twitter too.
I would like to monitor in real-time (< 10min) the retweets of all the tweets created by #FooWebsite.
For the moment, I think of using a cronjob that requests Twitter every minute to get info (number of retweets) about those tweets as I have their IDs.
Is there no subscription/callbacks like on Facebook API ?
I'm using PHP5.5 on Unix/Apache.
If you want to count Retweets as they happen in real time, the recommended way is to use the Streaming APIs.
In particular, the statuses/filter endpoint and its follow parameter will contain Retweets of any Tweet created by the user.
In order to distinguish these Retweets from the other Tweets streamed by the endpoint, you can rely on the presence of a retweeted_status nested object which will embed the original Tweet, allowing you to identify and focus exclusively on Retweets and count the ones you are interested in.
Please also note a retweet_count attribute value is attached to that node and represents, roughly, the number of times that original Tweet has been retweeted as of some time near when you were streamed the Tweet.

get recent tweets from twitter using API 1.1

I want to get recent tweets from twitter using API 1.1 .
I just don't want to get it only for current user or user's followers. I want to get all the tweets from all the users.
Is there a way by which I can get all user's tweets.
Is there any limit for this type of API call?
I want to fetch all the tweets at the application level, that means I won't be having any user token. How I can do this?
EDIT:
I found that we can use SEARCH API to search recent tweets using this
https://dev.twitter.com/docs/api/1.1/get/search/tweets
But In this API we have to pass the q parameter to search. But what if I don't want search based on specific parameter. I just want all the tweets from last 24 hours.
Is there way where I don't have to pass q in search API?
You want to call
https://stream.twitter.com/1.1/statuses/sample.json
This will allow you to get a random sample of the most recent tweets made by all users.
I am pretty sure there isn't any way to get all the tweets from all users at an application level. What you want to do is have your application store a version of each users tweet in a DB and then query the DB for that information. This approach also doesn't come with any call limits.
You look at a list of the available Twitter API v1.1 calls available in its REST API at:
https://dev.twitter.com/docs/api/1.1
The only application level call is:
GET application/rate_limit_status

Combine Facebook and Twitter Searches

I am making search requests to both Facebook and Twitter using an iPhone application, my issue is I require to combine the searches into a single view, so to go about this I intend to make a request to an individual script on my server, which will then make the requests to both Facebook and Twitter, decode the JSON results, combine them, order by date and then output once again in JSON. This JSON will be fetched by my iPhone application, decoded and placed into a table view.
Whilst I have the client side part sorted, and am capable of making requests in PHP to obtain Facebook and Twitter search results, I have no idea how to combine them and order by date, given that the JSON keys/entities for Facebook and Twitter are different. They don't both use the same key for date, for example. How would I go about doing this?
Some code examples would be great.
Is there something preventing you from creating your own data object or storage method with a way to parse a Facebook or Twitter result into it? If both results have different keys for the date as you say, you would just translate it into something you can parse.

Tumblr - Facebook post like status statistics

I want to implement the following features.
From my server I want to write a script which will authenticate a user's tumblr and facebook account and will extract
like statistics comparison data
from corresponding posts.
Anyone have any ideas.
I tired to extract the information using the tumblr API but did not get any useful information to fulfill the requirements
Tumblr likes are classed as post notes.
From the API documentation you can get post note information as follows:
http://api.tumblr.com/v2/blog/BLOGNAME.tumblr.com/posts?id=XXXX&notes_info=true
Adding the parameter notes_info=true will return the note / like count.

Categories