本文整理匯總了PHP中Twitter::tweet方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twitter::tweet方法的具體用法?PHP Twitter::tweet怎麽用?PHP Twitter::tweet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Twitter
的用法示例。
在下文中一共展示了Twitter::tweet方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: twitter
public static function twitter($title)
{
$twitter = new Twitter();
if ($twitter->tweet($title)) {
return true;
}
return false;
}
示例2: newUpdate
function newUpdate($data)
{
if (empty($data['incidents_id'])) {
throw new Exception('An incident ID must be specified');
}
if (empty($data['message'])) {
throw new Exception('A message must be specified');
}
if (empty($data['visible'])) {
$data['visible'] = 1;
}
if (empty($data['twitterpost'])) {
$data['twitterpost'] = false;
}
if (empty($data['timeadded'])) {
$data['timeadded'] = time();
}
$sql = $this->db->prepare("SELECT * FROM incidents WHERE id=:iid LIMIT 1");
$sql->bindValue(':iid', $data['incidents_id'], SQLITE3_INTEGER);
$results = $sql->execute();
if ($results === false) {
return new Exception('Database error attempting to locate incident');
}
$incident = $results->fetchArray(SQLITE3_ASSOC);
if (!isset($incident['timeopened'])) {
throw new Exception('Invalid Incident ID provided');
}
$sql = $this->db->prepare("INSERT INTO incidents_updates (incidents_id, timeadded, message, visible) VALUES (:iid, datetime(:timeadded, 'unixepoch'), :message, :visible)");
$sql->bindValue(':iid', $data['incidents_id'], SQLITE3_TEXT);
$sql->bindValue(':timeadded', $data['timeadded'], SQLITE3_INTEGER);
$sql->bindValue(':message', $data['message'], SQLITE3_TEXT);
$sql->bindValue(':visible', $data['visible'], SQLITE3_INTEGER);
$insert = $sql->execute();
if ($data['twitterpost']) {
$twitter = new Twitter();
$twitter->tweet($data['message']);
}
if ($insert === false) {
throw new Exception('Unexpected error when attempting to add new incident update');
}
return $this->db->lastInsertRowID();
}
示例3: foreach
foreach ($replacements as $k => $v) {
$entified_tweet = substr_replace($entified_tweet, $v, $k, strlen($keys[$k]));
}
return $entified_tweet;
}
}
class Twitter
{
const CONSUMER_KEY = '';
const CONSUMER_SECRET = '';
const ACCESS_TOKEN = '';
const ACCESS_TOKEN_SECRET = '';
/**
* Will post a tweet to the twitter account
* @param string $text
*/
function tweet($text)
{
$connection = new tmhOAuth(array('consumer_key' => Twitter::CONSUMER_KEY, 'consumer_secret' => Twitter::CONSUMER_SECRET, 'user_token' => Twitter::ACCESS_TOKEN, 'user_secret' => Twitter::ACCESS_TOKEN_SECRET));
// Make the API call
$connection->request('POST', $connection->url('1/statuses/update'), array('status' => $text));
return $connection->response['code'];
}
}
printf('Send deploy notification to Twitter');
$cap_environment = $argv[1];
$cap_deploy_version = $argv[2];
$twitter = new Twitter();
$twitter->tweet("Deployed cap version {$cap_deploy_version} to {$cap_environment}");
return true;
// exit(0);