本文整理匯總了PHP中Twitter::Follow方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twitter::Follow方法的具體用法?PHP Twitter::Follow怎麽用?PHP Twitter::Follow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Twitter
的用法示例。
在下文中一共展示了Twitter::Follow方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: switch
}
break;
case 'x-twitteremailtype':
case 'x-twittersendername':
case 'x-twittersenderscreenname':
$headers[$key] = $val;
break;
}
}
if (!empty($headers['x-twitteremailtype']) and !empty($headers['x-twittersendername']) and !empty($header['x-twittersenderscreenname'])) {
// Mark it as seen now to minimise the possibility of clashes
$processed++;
switch ($headers['x-twitteremailtype']) {
case 'is_following':
// Note that we handle the case where we're already following a user and don't try to re-create them
$user = Twitter::Follow($headers['x-twittersenderscreenname']);
if (isset($user['error']) and stripos($user['error'], 'already on your list') === false) {
echo 'Follow failed for "' . $headers['x-twittersenderscreenname'] . '": ' . $user['error'] . "\n";
} elseif (stripos(@$user['error'], 'already on your list') !== false or User::Create($user)) {
Twitter::Tweet('d ' . $headers['x-twittersenderscreenname'] . ' Welcome to Replies from TwitApps. Send your email address by direct message to @' . $_twitter['username'] . ' to activate this service.');
} else {
echo 'Failed to create user "' . $headers['x-twittersenderscreenname'] . '": ' . mysql_error(GetDB()) . "\n";
}
break;
case 'direct_message':
// Direct message should contain a command or an email address
$body = imap_body($mbox, $msgid, FT_PEEK);
$email = false;
foreach (preg_split('/\\s/', strtolower($body)) as $word) {
switch ($word) {
case 'start':
示例2: mail
<?php
if (empty($info['headers']['x-twitteremailtype']) or empty($info['headers']['x-twittersendername']) or empty($info['headers']['x-twittersenderscreenname'])) {
mail('contact@twitapps.com', 'TwitApps incoming mail: Missing header(s)', $body . "\n\n========================================\n\n" . $data, 'From: TwitApps <contact@twitapps.com>', '-fcontact@twitapps.com');
} else {
require dirname(__FILE__) . '/../fx.php';
switch ($info['headers']['x-twitteremailtype']) {
case 'is_following':
// Note that we handle the case where we're already following a user and don't try to re-create them
$user = Twitter::Follow($info['headers']['x-twittersenderscreenname']);
if (isset($user['error']) and stripos($user['error'], 'already on your list') === false) {
echo 'Follow failed for "' . $info['headers']['x-twittersenderscreenname'] . '": ' . $user['error'] . "\n";
} elseif (stripos(@$user['error'], 'already on your list') !== false or User::Create(isset($user['screen_name']) ? $user : array('screen_name' => $info['headers']['x-twittersenderscreenname']))) {
Twitter::Tweet('d ' . $info['headers']['x-twittersenderscreenname'] . ' Welcome to Follows from TwitApps. Send your email address by direct message to @' . $_twitter['username'] . ' to activate this service.');
} else {
echo 'Failed to create user "' . $info['headers']['x-twittersenderscreenname'] . '": ' . mysql_error(GetDB()) . "\n";
}
break;
case 'direct_message':
// Direct message should contain a command or an email address
$email = false;
foreach (preg_split('/\\s/', strtolower($body)) as $word) {
switch ($word) {
case 'start':
//echo 'Start for "'.$info['headers']['x-twittersenderscreenname'].'"'."\n";
$user = Twitter::GetUserDetails($info['headers']['x-twittersenderscreenname']);
if ($user and User::SetStatus($info['headers']['x-twittersenderscreenname'], 'active', $user->status->id)) {
$dm = 'Sorted! I\'ll start sending you emails again shortly.';
} else {
$dm = 'Grrr, something went wrong restarting your emails. I\'ve notified the team and they\'ll look into it ASAP.';
echo ' Failed to start emails for "' . $info['headers']['x-twittersenderscreenname'] . '"' . "\n\n";