I am working on sentiment analysis for which I need twitter feed. I have implemented the php code to get the json feed and parse it as I wanted. the problem is I could not find a way to get json feed as per the date specified.
$query = array(
'screen_name' => 'twitterapi',
'count' => '5'
);
Using the above syntax I have to specify the number of tweets but my requirement is to get the feed for specific date. Is it possible to pass date parameter instead of count.
currently I am using $path = '/1.1/statuses/user_timeline.json';
I have also implemented the mechanism to manually filter the date but for that I have to provide very large count for older dates that unnecessarily slows down the code.
There are two ways you can do this.
Firstly, read the documentation for the API call you're making. You can't pass a date - but you can request up to 200 Tweets and, if that isn't enough, page through up to 3,200 of their most recent tweets.
Secondly, read the documentation for Searching Twitter, you can use the until parameter to search for older Tweets. Twitter's search API only goes back ~7 days. As they say:
Please note that Twitter’s search service and, by extension, the Search API is not meant to be an exhaustive source of Tweets. Not all Tweets will be indexed or made available via the search interface.
Related
I am using Google Search Console for php to obtain search analytics of my website. I know Google provides data for 90 days, but the end date to that range is not the current date, but usually a couple days prior. Is there a simple way to find the true end date for the data provided? I know I could send requests for recent days and work backwards until a result is returned, but I feel there must be a better way.
The Search Console provides the Search Data 3 days later. So today (20.06.) you see the data from 17.06. You just have to check at what time the data apears. This is form SC to SC a little bit different.
I'm using this link to get popular tweets (in English for example)
https://api.twitter.com/1.1/search/tweets.json?q=('[]')&lang=en&result_type=popular&count=100
But it GETs the popular tweets in current week. Because of this, the result of it is repetitious! If you see its result ever and ever in one day, the same tweets you will see!
but how can I change the period of it? for example just GET the popular tweets since yesterday?
I tried to use since ID field but it's Non-variable.
I'm using PHP.
I have a PHP script that processes parameters, converts them to relevant YAPIV3 params and turns it into a query string for the YouTube API V3.
A sample string can be:
https://www.googleapis.com/youtube/v3/playlistItems?part=snippet%2CcontentDetails%2Cstatus&maxResults=50&playlistId=UU-S6cXyil4qbIPfb2hrcH4w&key=AIzaSyDpFFK1zQpXvUgOghKYriA9LYtrI-B9QLc&publishedBefore=2016-12-03T15:20:54+00:00&publishedAfter=2016-11-28T15:20:54+00:00
However, unlike the search list documentation the publishedBefore and publishedAfter aren't accepted parameters.
All I want to do is get a list of a users videos between two points.
https://developers.google.com/youtube/v3/docs/playlistItems/list
https://developers.google.com/youtube/v3/docs/search/list
Can anyone suggest a query string using /v3/search service to achieve what I'd like to do?
i am searching for a way to retrieve the number of search results (like on google result pages) for a given query.
the aim is to implementent the normalized google distance (http://iknowate.blogspot.com/2011/10/google-similarity-distance.html) using a search api; the main problem is that the number of requests shouldnt be too limited (google api seems to allow only ~100 queries / day).
maybe someone could give me a hint how i could retrieve this information.
You could either use a third party library/class to scrape the results page and then traverse the DOM to get your info or use file_get_contents to get the page and then use preg_match to get the total number of results. Another option would be to scrape the page using CURL which would also enable you to hide your script behind multiple Agents to prevent any kind of bans if you intend to scrape pages multiple times.
I want to calculate the number of Tweets of a Twitter Search, and a countup. Just like GigaTweet. How can I calculate this using PHP and the Twitter API?
There are plenty of documents and PHP libraries out there to assist you with this:
http://apiwiki.twitter.com/Libraries#PHP
http://apiwiki.twitter.com/Twitter-API-Documentation
As for the specific method I would use:
- http://apiwiki.twitter.com/Twitter-Search-API-Method:-search
Example:
- http://search.twitter.com/search.atom?q=twitter
I would then use simplexml (http://www.php.net/simplexml) to parse the atom feed. From there I would use the count method to get the number of "entry" items in that feed.
Please keep in mind that the atom format uses xml namespaces and you'll have to use the children method to retrieve items correctly. More on this can be found here: http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/