Comments (9)
Could you paste the code you are using?
from twitter-api-php.
$url = 'https://api.twitter.com/1.1/search/tweets.json';
$getfield = '?q=%23mitthverfi&result_type=mixed&count=5';
$requestMethod = 'GET';
from twitter-api-php.
Here is the whole code
require_once('TwitterAPIExchange.php');
/** Set access tokens here - see: https://dev.twitter.com/apps/ **/
$settings = array(
'oauth_access_token' => "#####",
'oauth_access_token_secret' => "#####",
'consumer_key' => "#####",
'consumer_secret' => "#####"
);
$url = 'https://api.twitter.com/1.1/search/tweets.json';
$getfield = '?q=%23mitthverfi&count=5';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
$api_response = $twitter ->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
$response = json_decode($api_response);
if (!empty($response)) :
foreach ($response->statuses as $tweet) :
$datetime = $tweet->created_at;
$date = date('M d, Y', strtotime($datetime));
$time = date('g:ia', strtotime($datetime));
$tweet_text = $tweet->text;
// check if any entites exist and if so, replace then with hyperlinked versions
foreach ($tweet->entities->urls as $url) {
$find = $url->url;
$replace = '<a href="'.$find.'">'.$find.'</a>';
$tweet_text = str_replace($find,$replace,$tweet_text);
}
foreach ($tweet->entities->hashtags as $hashtag) {
$find = '#'.$hashtag->text;
$replace = '<a href="http://twitter.com/#!/search/%23'.$hashtag->text.'">'.$find.'</a>';
$tweet_text = str_replace($find,$replace,$tweet_text);
}
foreach ($tweet->entities->user_mentions as $user_mention) {
$find = "@".$user_mention->screen_name;
$replace = '<a href="http://twitter.com/'.$user_mention->screen_name.'">'.$find.'</a>';
$tweet_text = str_ireplace($find,$replace,$tweet_text);
}
echo '<div class="col_twitter">
<div class="avatar_col"><img src="'."{$tweet->user->profile_image_url_https}".'" width="21" height="21"></div>
<div class="twitter_text">
<div class="info_text"><strong>';
echo "{$tweet->user->name}".'</strong> @'."{$tweet->user->screen_name}".'</div>';
echo '<p>'.$tweet_text.'</p></div>';
echo '<div class="twitter_links"><a href="https://twitter.com/intent/tweet?in_reply_to='."{$tweet->id}".'" target="_blank">Reply</a> <a href="https://twitter.com/intent/retweet?tweet_id='."{$tweet->id}".'" target="_blank">Retweet</a> <a href="https://twitter.com/intent/favorite?tweet_id='."{$tweet->id}".'" target="_blank">Favorite</a></div>';
echo '</div>';
endforeach;
endif;
from twitter-api-php.
Could you try changing your "%23" to a #
character and try again (just interested if this works without having to encode the has anyway)? I'll take a look at this in a little while.
from twitter-api-php.
I have tried that also but that did not change anything.
from twitter-api-php.
Also, the API docs show you can use &result_type=recent
to fetch the most recent ones. I'll take a look at the count soon, but the twitter API doesn't always return the exact tweets that they have - it's not always up-to-date - you can view this in the FAQ here:
Why are the Tweets I'm looking for not in Twitter Search, the Search API, or Search widgets?
Twitter's search is optimized to serve relevant tweets to end-users in response to direct, non-recurring queries such as #hashtags, URLs, domains, and keywords. The Search API (which also powers Twitter's search widget) is an interface to this search engine. Our search service is not meant to be an exhaustive archive of public tweets and not all tweets are indexed or returned. Some results are refined to better combat spam and increase relevance. Due to capacity constraints, the index currently only covers about a week's worth of tweets.
The user timeline API is the definitive source of tweets by a specific author. For a collection of recent Tweets by more than one user, consider creating a Twitter List and leveraging the list timeline. The Streaming API is often the best-fit choice when seeking completeness.
If the tweets you're looking for aren't available in search and you think they should be, consult this support topic for further instructions to contact @Support.
from twitter-api-php.
Yes I have tested the recent result_type also but to no avail. I know about this Twitter search thing, I have read the FAQ about this but it just baffles me why the count variable does not work when I want maby just one more Tweet (5 instead of 4) but when I ask for just 1 that works !
from twitter-api-php.
Hi again. Have you had the chance to look at this ?
from twitter-api-php.
Very old post, sorry... but this should be fixed :-)
from twitter-api-php.
Related Issues (20)
- How can I get Exception issue ?
- Post 280 character HOT 3
- Double posting when posting an image. HOT 3
- Blocking some accounts with this package
- Premium activity webhook event not generating log
- No response deleting DM HOT 1
- engagement endpoint
- Generate access token for other accounts.
- Is this working with Twitter Labs? HOT 1
- Unknown SSL protocol error in connection to api.twitter.com:443
- Fatal error: Uncaught Error: Call to a member function buildOauth() on null HOT 5
- List endpoints requiring POST method do not work
- Twitter API V2? HOT 1
- No longer working?
- Can not send direct message HOT 1
- Licence
- Too slow...
- Important Updated needed for Doc, about get user Data > email HOT 3
- Parse Error
- Exception in TwitterAPIExchange.php file HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twitter-api-php.