本文整理匯總了PHP中Twitter::Search方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twitter::Search方法的具體用法?PHP Twitter::Search怎麽用?PHP Twitter::Search使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Twitter
的用法示例。
在下文中一共展示了Twitter::Search方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Twitter
Copyright (c) 2009 Vladimir Ignatyev & Ridev corp., http://www.ridev.ru/
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
require_once 'twitter/twitter.inc';
$T = new Twitter('Username', 'Password');
$result = $T->Search(array('q' => 'Twitter'));
if (!$result) {
$err = $T->GetLastError();
echo "ErrCode: {$err['ErrNo']}\n\nMessage: {$err['Message']}";
}
var_dump($result);
示例2: time
}
@($GLOBALS['apihits']['replies_emails'] = 0);
$endtime = time() + 60 * 15;
while (time() < $endtime) {
$sleep = true;
// Don't even try if we're rate limited
$limited = cache('get', KEY_SEARCH_LIMITED) !== false;
$user = $limited ? false : User::GetNext();
if ($user !== false) {
$sleep = false;
$user['last_run_at'] = time();
$searchterm = ($user['replies_only'] == 1 ? 'to:' : '@') . $user['username'];
if ($user['ignore_self'] == 1) {
$searchterm .= ' -from:' . $user['username'];
}
$searchresults = Twitter::Search($searchterm, $user['last_id']);
if ($searchresults === false) {
// Search failed, do nothing
} else {
list($user['last_id'], $replies) = $searchresults;
if (count($replies) > 0) {
//echo "Got ".count($replies)." results for ".$user['username']."\n";
foreach ($replies as $reply) {
Queue::Add($user['username'], $reply['id'], strtotime($reply['created_at']), $reply);
}
}
$num = Queue::Num($user['username']);
if ($num > 0 and ($num >= $user['max_queued'] or $user['last_email_at'] < time() - $user['min_interval'])) {
if (!Queue::SendEmail($user['username'], $user['email'])) {
// Message NOT sent
echo 'Failed to send the email to "' . $user['username'] . '"' . "\n";
示例3: Twitter
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
require_once 'twitter/twitter.inc';
$T = new Twitter('Username', 'Password');
$tosearch = 'coding';
// string to search
$result = $T->Search(array('q' => $tosearch));
if (!$result) {
$err = $T->GetLastError();
echo "ErrCode: {$err['ErrNo']}\n\nMessage: {$err['Message']}";
}
$users_to_follow = array();
foreach ($result->results as $record) {
array_push($users_to_follow, $record->from_user);
}
foreach ($users_to_follow as $user) {
$result = $T->UsersShow(array('screen_name' => $user));
$id = $result->id;
$screen_name = $result->screen_name;
$result = $T->FriendshipsCreate(array('follow' => 'true'), $screen_name);
}