本文整理汇总了PHP中TwitterOAuth::post方法的典型用法代码示例。如果您正苦于以下问题:PHP TwitterOAuth::post方法的具体用法?PHP TwitterOAuth::post怎么用?PHP TwitterOAuth::post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TwitterOAuth
的用法示例。
在下文中一共展示了TwitterOAuth::post方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addPost
/**
* Adds a post to Twitter
*
* @param string $question Question
* @param string $tags String of tags
* @param string $link URL to FAQ
*
* @return void
*/
public function addPost($question, $tags, $link)
{
$hashtags = '';
if ($tags != '') {
$hashtags = '#' . str_replace(',', ' #', $tags);
}
$message = PMF_String::htmlspecialchars($question);
$message .= ' ' . $hashtags;
$message .= ' ' . $link;
$this->connection->post('statuses/update', array('status' => $message));
}
示例2: push
public function push($Account, $TwitterStatus)
{
$NGPushIni = eZINI::instance('ngpush.ini');
$Token = self::getToken($Account);
if (!$Token) {
self::requestToken($Account);
$Token = self::getToken($Account);
}
if ($Token) {
$tokenCredentials = explode('%%%', $Token);
$connection = new TwitterOAuth($NGPushIni->variable($Account, 'ConsumerKey'), $NGPushIni->variable($Account, 'ConsumerSecret'), $tokenCredentials[0], $tokenCredentials[1]);
$connection->host = "https://api.twitter.com/1.1/";
$TwitterResponse = $connection->post('statuses/update', array('status' => $TwitterStatus));
self::$response['response'] = $TwitterResponse;
//Let's analyize some Twitter JSON response (lots of data but no clear structure and no status)
if ($TwitterResponse->error) {
self::$response['status'] = 'error';
self::$response['messages'][] = $TwitterResponse->error;
} elseif ($TwitterResponse->errors) {
self::$response['status'] = 'error';
foreach ($TwitterResponse->errors as $TwitterResponseError) {
self::$response['messages'][] = $TwitterResponseError->message;
}
} else {
self::$response['status'] = 'success';
if ($TwitterResponse->created_at) {
self::$response['messages'][] = 'Status is published!';
}
}
} else {
self::$response['status'] = 'error';
self::$response['messages'][] = 'You need access token to use this application with Twitter.';
}
return self::$response;
}
示例3: post
function post($message)
{
error_reporting(0);
$acces = array('consumer_key' => $this->auth['consumer_key'], 'consumer_secret' => $this->auth['consumer_secret'], 'access_token' => $this->auth['access_token'], 'access_secret' => $this->auth['access_secret']);
$twitter = new TwitterOAuth($acces['consumer_key'], $acces['consumer_secret'], $acces['access_token'], $acces['access_secret']);
$response = $twitter->post('statuses/update', array('status' => $message));
}
示例4: postMessage
public static function postMessage($params, $data)
{
$attachment = array('message' => $data['message']);
$message = array();
if (!class_exists('TwitterOAuth')) {
require_once dirname(__FILE__) . '/elements/twitter/twitteroauth.php';
}
$user = $params->params->get('groupid');
$checked = 0;
$log = '';
$publish = 1;
if (isset($user->checked)) {
$checked = 1;
$twitter = unserialize($params->params->get('access_token'));
$connection = new TwitterOAuth($params->params->get('app_appid'), $params->params->get('app_secret'), $twitter['oauth_token'], $twitter['oauth_token_secret']);
$parameters = array('status' => $attachment['message']);
$status = $connection->post('statuses/update', $parameters);
if (isset($status->errors)) {
$log = Jtext::_('PUBLISHED_TWITTER_PROFILE_SENDMESSAGE') . ' <a href="https://twitter.com/' . $user->screen_name . '" target="_blank" style="text-decoration: underline;">' . $user->name . '</a> - ' . $status->errors[0]->message . ' <br/>';
$publish = 0;
} else {
$log = Jtext::_('PUBLISHED_TWITTER_PROFILE_SENDMESSAGE') . ' <a href="https://twitter.com/' . $user->screen_name . '" target="_blank" style="text-decoration: underline;">' . $user->name . '</a> - ' . JTEXT::_('PUBLISHED_TWITTER_PROFILE_SENDMESSAGE_SUCCESSFULL') . '<br/>';
$publish = 1;
}
}
$message['log'] = $log;
$message['publish'] = $publish;
$message['checked'] = $checked;
$message['type'] = 'twitter';
return $message;
}
示例5: xAction
/**
* @Route("/souphpsp/x")
*/
public function xAction()
{
$oauth = new \TwitterOAuth('qPLsh4YhO2Ui8KmM6vRtw', 'CbtjJPSD1yxxJfbbr4TPKX7K0UCExnffk5Qg', '18179550-Z6V17Ly1tvyOEiqCjuq1NfenI71FacvFrlqYT8Bqb', 'CkS51WZMERauimVxZBOxVQVLtBeDzIZCFLzCQpGzlg');
$res = $oauth->post('http://api.twitter.com/1/direct_messages/new.json', array('screen_name' => 'rdohms', 'text' => 'mytext'));
var_dump($res);
return new \Symfony\Component\HttpFoundation\Response();
}
示例6: post
public static function post($user, $text)
{
$culture = $user->getCulture();
$profile = $user->getGuardUser()->getProfile();
$connection = new TwitterOAuth(sfConfig::get("app_twitter_api_consumer_key_{$culture}"), sfConfig::get("app_twitter_api_consumer_secret_{$culture}"), $profile->getTwOauthToken(), $profile->getTwOauthTokenSecret());
$connection->post('statuses/update', array('status' => $text));
}
示例7: post_on_behalf_of
function post_on_behalf_of($user, $message) {
if (!empty($user['tw_oauth_token']) && !empty($user['tw_oauth_token_secret'])) {
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $user['tw_oauth_token'], $user['tw_oauth_token_secret']);
$resp = $connection->post('statuses/update', array('status' => $message));
return (200 == $connection->http_code);
}
}
示例8: message
public function message($userID, $text)
{
/* Create a TwitterOauth object with consumer/user tokens. */
$connection = new TwitterOAuth($this->appCode, $this->appSecret, $this->token['oauth_token'], $this->token['oauth_token_secret']);
/* Get logged in user to help with tests. */
$request = (array) $connection->post('direct_messages/new', array('user_id' => $userID, 'text' => $text));
return true;
}
示例9: statusesUpdate
public static function statusesUpdate($oauthToken, $oauthTokenSecret, $status, array $extraData = array())
{
list($consumerKey, $consumerSecret) = bdSocialShare_Option::getTwitterConsumerPair();
$twitter = new TwitterOAuth($consumerKey, $consumerSecret, $oauthToken, $oauthTokenSecret);
$response = $twitter->post('statuses/update', array_merge(array('status' => $status), $extraData));
$responseArray = (array) $response;
return $responseArray;
}
示例10: postDirectContentOnTwitter
public function postDirectContentOnTwitter($content, $user_token, $user_secret)
{
$status_update = $content;
include_once '../Vendor/twitter/twitter/lib/twitteroauth.php';
include_once '../Vendor/twitter/twitter/lib/secret.php';
$connectionNew = new TwitterOAuth(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, $user_token, $user_secret);
$connectionNew->post('statuses/update', array('status' => $status_update));
}
示例11: postContentOnTwitter
public function postContentOnTwitter($content, $id, $user_token, $user_secret){
$link = SITE_PATH.'business_feeds/view_feed_content/'.$this->Fp->encrypt($id);
$status_update = $content['message'].' '.$link;
include_once('../Vendor/twitter/twitter/lib/twitteroauth.php');
include_once('../Vendor/twitter/twitter/lib/secret.php');
$connection = new TwitterOAuth(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, $user_token, $user_secret);
$connection->post('statuses/update', array('status'=>$status_update));
}
示例12: post
function post($message = "hello")
{
// $message
$connection = new TwitterOAuth(WRA_CONF::$twiappid, WRA_CONF::$twiappsecret, $this->oauth_token, $this->oauth_token_secret);
// $content = $connection->get('account/rate_limit_status');
$res = $connection->post('statuses/update', array('status' => $message));
// WRA::debug($res);
// $content = $connection->get('users/show',array('user_id'=> $_SESSION['access_token']['user_id']));
}
示例13: data
public function data()
{
$this->_mandatory(array('message'));
$message = $this->input->post('message');
$config = new Controllers_Api_Twitter_Config_App();
$connection = new TwitterOAuth($config->config['consumer_key'], $config->config['consumer_secret'], $_REQUEST['token_twitter'], $_REQUEST['token_secret_twitter']);
//Post text to twitter
$my_update = $connection->post('statuses/update', array('status' => $message));
echo json_encode($my_update);
}
示例14: _tweet_report
public function _tweet_report()
{
$report = Event::$data;
$tweet = $report->incident_title . ' @ ' . $report->location->location_name . ' http://boskoi.org/' . $report->id;
//fb($tweet,'Tweet text');
$tw = new TwitterOAuth(Kohana::config('tweetkoi.consumer_key'), Kohana::config('tweetkoi.consumer_secret'), Kohana::config('tweetkoi.oauth_token'), Kohana::config('tweetkoi.oauth_token_secret'));
$result = $tw->post('statuses/update', array('status' => $tweet));
print_r($result);
return true;
}
示例15: sendTweet
/**
* Sends a tweet
*
* @param string $txt the tweet text to send
* @param bool $limit DEPRECATED
*
* @return string URL of tweet (or false on failure)
*/
public function sendTweet($txt, $limit = false)
{
if (!$this->authenticatedAsUser) {
return false;
}
$resp = $this->api->post('statuses/update', array('status' => $txt));
if (200 != $this->api->lastStatusCode()) {
return false;
}
return $resp;
}