Answer the question
In order to leave comments, you need to log in
Problem with searching multiple words via Twitter API (PHP)?
Good evening, I'm using the following code to search twitter:
<?php
require("twitteroauth/autoload.php");
use Abraham\TwitterOAuth\TwitterOAuth;
define('CONSUMER_KEY', '-'); /
define('CONSUMER_SECRET', '-');
define('ACCESS_TOKEN', '-');
define('ACCESS_TOKEN_SECRET', '-');
function search(array $query)
{
$toa = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
return $toa->get('search/tweets', $query);
}
$query = [
"q" => "Путин+заявление",
];
$results = search($query);
if ($results->statuses == NULL){
echo "<b> Совпадений по слову _" . $query["q"] . "_ не найдено </b> <br>";
} else {
foreach ($results->statuses as $result) {
echo $result->user->screen_name . ": " . $result->text . "<br>";
}
}
?>
Answer the question
In order to leave comments, you need to log in
That's it, I read the manual more carefully and saw that, unfortunately:
"Keep in mind that the search index has a 7-day limit. In other words, no tweets will be found for a date older than one week."
It's over, maybe this is nonsense, but try to lowercase the string
mb_strtolower ("Putin+statement+Kremlin")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question