本文整理匯總了PHP中Twitter::getSearch方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twitter::getSearch方法的具體用法?PHP Twitter::getSearch怎麽用?PHP Twitter::getSearch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Twitter
的用法示例。
在下文中一共展示了Twitter::getSearch方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
public function __construct()
{
if (Agent::isMobile()) {
$this->_vista = 'mobile';
} else {
$this->_vista = 'index';
}
$this->_imagesInstagram = array();
$this->_imagesTwitter = array();
$instagram = new instagram(array('apiKey' => '09fd60952ea742d5abb761b6c6a137aa', 'apiSecret' => 'ee25063e91e74d6c9f257be054a44ec3', 'apiCallback' => 'http://viernesdezapatillas.pe/'));
$tagInstagram = 'viernesdezapatillas';
$numphotosInstagram = 15;
$media = $instagram->getTagMedia($tagInstagram, $auth = false, array('count' => $numphotosInstagram));
$response = json_decode(json_encode($media));
foreach ($response->data as $data) {
$this->_imagesInstagram[] = $data->images->thumbnail->url;
}
$max_id = 0;
$totalTweets = 15;
$responset = Twitter::getSearch(array('q' => '#viernesdezapatillas since:2015-07-01 filter:images', 'count' => $totalTweets, 'max_id' => $max_id, 'since_id' => 0));
foreach ($responset->statuses as $tweet) {
foreach ($tweet->entities->media as $url) {
$this->_imagesTwitter[] = $url->media_url;
// . ':thumb';
}
}
}
示例2: function
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
use GrahamCampbell\Markdown\Facades\Markdown;
Route::get('/original', function () {
return view('inicio-original');
});
Route::get('/twitter/{hashtag}', function ($hashtag) {
$twitters = Twitter::getSearch(['q' => $hashtag, 'count' => 50]);
$sentimientos = ['negative', 'positive', 'neutral'];
$twitters_array = $twitters->statuses;
foreach ($twitters_array as $twitter) {
$traduccion = TranslateClient::translate('es', 'en', $twitter->text);
$sentimiento = SentimentAnalysis::decision($traduccion);
$sentimientos[] = $sentimiento;
}
$sentimiento_twitter = array_count_values($sentimientos);
return view('twitter', compact('sentimiento_twitter', 'twitters_array', 'hashtag'));
});
Route::get('/sentimiento/{text}', function ($text) {
$traduccion = TranslateClient::translate('es', 'en', $text);
return SentimentAnalysis::decision($traduccion);
});
Route::get('/colaboradores', function () {
示例3: function
});
/**
* Registers the GET route to the codezero/twitter package test page.
*/
Route::get('/twitter/codezero', function () {
$config = __DIR__ . '/../../config/twitter.php';
$twitter = new CodeZero\Twitter\Twitter($config);
$tweets = $twitter->searchTweets('taylorswift', 50);
dump($tweets);
return 'codezero/twitter';
});
/**
* Registers the GET route to the thujohn/twitter package test page.
*/
Route::get('/twitter/thujohn', function () {
$search_results = Twitter::getSearch(['q' => 'taylorswift', 'lang' => 'en', 'result_type' => 'popular']);
dump($search_results);
echo '<h1>Tweets</h1>';
foreach ($search_results->statuses as $tweet) {
// $info = Oembed::cache(Twitter::linkTweet($tweet), []);
// echo $info->code;
echo '<iframe class="twitter-tweet" ';
echo ' src="http://twitframe.com/show?url=', urlencode(Twitter::linkTweet($tweet)), '"';
echo ' frameborder="0"';
echo ' height="480">';
echo '</iframe>';
// echo Twitter::linkify($tweet),
// '<br/><a href=',
// Twitter::linkTweet($tweet), '>',
// Carbon\Carbon::createFromFormat('D M d H:i:s P Y',
// $tweet->created_at),
示例4: showBoard
//.........這裏部分代碼省略.........
$post['post_type'] = 'image';
} else {
if ($post['type'] == 'video' && isset($post['picture'])) {
$post['post_type'] = 'video';
$post['img_url'] = $post['picture'];
$post['embed'] = $post['link'];
} else {
$post['post_type'] = 'text';
}
}
if (isset($post['message'])) {
$post['caption'] = $post['message'];
}
$post['date_created'] = $post['created_time'];
array_push($posts, $post);
$count++;
}
if (isset($facebook['paging'])) {
if (isset($facebook['paging']['previous'])) {
$prev = $facebook['paging']['previous'];
parse_str($prev, $arr);
$facebookSinceId = $arr['since'];
}
if (isset($facebook['paging']['next'])) {
$next = $facebook['paging']['next'];
parse_str($next, $arr);
$facebookUntilId = $arr['until'];
}
}
}
}
if ($config->has_tw != -1) {
$first = true;
$twitter = Twitter::getSearch(array('q' => '#' . $hashtag, 'include_entities' => 1, 'result_type' => 'recent', 'count' => $postCount));
if ($twitter) {
foreach ($twitter->statuses as $tweet) {
if (substr($tweet->text, 0, 2) !== "RT") {
if ($first) {
$twitterSinceId = $tweet->id . '';
$first = false;
}
$post['vendor'] = 'twitter';
$post['post_id'] = $tweet->id;
$post['user_id'] = $tweet->user->id;
$post['username'] = $tweet->user->screen_name;
$post['user_img_url'] = $tweet->user->profile_image_url;
if (isset($tweet->entities->media)) {
$post['img_url'] = $tweet->entities->media[0]->media_url;
$post['post_type'] = 'image';
} else {
$post['post_type'] = 'text';
}
$str = $tweet->text;
$str = preg_replace('/@([\\w-]+)/i', '', $str);
$post['caption'] = $str;
$post['date_created'] = date("m-d-y H:i:s", strtotime($tweet->created_at));
array_push($posts, $post);
$count++;
}
}
if (isset($twitter->search_metadata->next_results)) {
$next = $twitter->search_metadata->next_results;
parse_str($next, $arr);
$twitterMaxId = $arr['?max_id'];
} else {
$twitterMaxId = '';
示例5: searchTwitter
/**
* Searches Twitter for the specified $hashtag.
*
* @example array($tweet1, $tweet2, $tweet3)
* @param string $term hashtag term to search for
* @return array|object
*/
protected function searchTwitter($term)
{
$search_results = \Twitter::getSearch(['q' => $term, 'lang' => 'en', 'result_type' => 'popular', 'count' => 30]);
return $search_results->statuses;
}