当前位置: 首页>>代码示例>>PHP>>正文


PHP TwitterOAuth::post方法代码示例

本文整理汇总了PHP中Abraham\TwitterOAuth\TwitterOAuth::post方法的典型用法代码示例。如果您正苦于以下问题:PHP TwitterOAuth::post方法的具体用法?PHP TwitterOAuth::post怎么用?PHP TwitterOAuth::post使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Abraham\TwitterOAuth\TwitterOAuth的用法示例。


在下文中一共展示了TwitterOAuth::post方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: PostImage

 function PostImage()
 {
     if (!isset($_POST['source']) || $_POST['source'] == "") {
         return "Missing required params";
     }
     $config = (include "/config.php");
     $source = $_POST['source'];
     $final = "";
     if (isset($_POST['message'])) {
         $orig = $_POST['message'];
         $final = FilterText($orig);
     }
     $access_token = $_SESSION['access_token'];
     $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
     $check = new TB_Twitter_Check();
     if (!$check->VerifyTweet($source, $final)) {
         return "Tweet is not valid";
         exit;
     }
     $media1 = $connection->upload('media/upload', array('media' => $source));
     $parameters = array('status' => $final, 'media_ids' => implode(',', array($media1->media_id_string)));
     $result = $connection->post('statuses/update', $parameters);
     if ($connection->getLastHttpCode() == 200) {
         return "success";
     } else {
         return "An unnknown error occured";
     }
 }
开发者ID:thinkingboxmedia,项目名称:ShareAPI,代码行数:28,代码来源:twitter_post.php

示例2: provide

 /**
  * @param Article $article
  * @param string $header
  */
 public function provide(Article $article, $header = "")
 {
     $this->twitter->post("statuses/update", array("status" => "{$header} {$article->getTitle()} >> http://matomepp.net/p/{$article->getArticleId()}"));
     if ($this->twitter->getLastHttpCode() != 200) {
         throw new \RuntimeException(json_encode($this->twitter->getLastBody()));
     }
     $this->storeTweets($article);
 }
开发者ID:sat8bit,项目名称:matomepp,代码行数:12,代码来源:PickupTweetService.php

示例3: postStatus

 public function postStatus($status)
 {
     try {
         $connection = new TwitterOAuth($this->_consumerKey, $this->_consumerSecret, $this->_oauthToken, $this->_oauthSecret);
         $content = $connection->get('account/verify_credentials');
         $connection->post('statuses/update', array('status' => $status));
     } catch (Exception $e) {
         echo 'Caught exception: ', $e->getMessage(), "\n";
     }
 }
开发者ID:sonvq,项目名称:socialAutoPostingPHP,代码行数:10,代码来源:twitterStatus.php

示例4: TwitterLink

function TwitterLink()
{
    if ($_POST['checkTwitterLink'] != null) {
        require dirname(__FILE__) . '/twitteroauth/autoload.php';
        // OAuthオブジェクト生成
        $param = twitterparam();
        $connection = new TwitterOAuth($param[consumer_key], $param[consumer_secret], $param[access_token], $param[access_token_secret]);
        $postMessage = $param[title] . $_POST['post_title'] . " ";
        $url = $postMessage . get_permalink();
        //ツイート
        $res = $connection->post("statuses/update", array("status" => $url));
    }
}
开发者ID:T-maruNa,项目名称:tryWordPress,代码行数:13,代码来源:TwitterLink.php

示例5: delete

 /**
  * @return array|object|string
  */
 public function delete()
 {
     if ($this->id) {
         try {
             $post = $this->twitter->post('statuses/destroy/' . $this->id);
             return $post;
         } catch (Exception $e) {
             return $e->getMessage();
         }
     } else {
         return "Post id not set";
     }
 }
开发者ID:marvinosswald,项目名称:laravel-socialmedia,代码行数:16,代码来源:Post.php

示例6: loginTwitter

 public function loginTwitter($data)
 {
     if (!Session::has('access_token')) {
         $connection = new TwitterOAuth(config('socialpack.composer_key'), config('socialpack.composer_secret'));
         $callback_url = url('/') . '/callbackTwitter';
         $request_token = $connection->oauth('oauth/request_token', array('oauth_callback' => (string) $callback_url));
         Session::put('oauth_token', $request_token['oauth_token']);
         Session::put('oauth_token_secret', $request_token['oauth_token_secret']);
         $url = $connection->url('oauth/authorize', array('oauth_token' => $request_token['oauth_token']));
         return redirect()->away($url);
     } else {
         $access_token = Session::get('access_token');
         $connection = new TwitterOAuth(config('socialpack.composer_key'), config('socialpack.composer_secret'), $access_token['oauth_token'], $access_token['oauth_token_secret']);
         if (isset($data) && !empty($data)) {
             if (isset($data['profile']) && !empty($data['profile'])) {
                 if ($data['profile'] == "yes") {
                     // getting basic user info
                     $user = $connection->get("account/verify_credentials");
                     return $user;
                 }
             }
             if (isset($data['post_tweet']) && !empty($data['post_tweet'])) {
                 if ($data['post_tweet']["show"] == "yes") {
                     // posting tweet on user profile
                     $post = $connection->post('statuses/update', array('status' => $data['post_tweet']["message"]));
                     return $post;
                 }
             }
             if (isset($data['recent_tweets']) && !empty($data['recent_tweets'])) {
                 if ($data['recent_tweets']["show"] == "yes") {
                     // getting recent tweeets by user 'snowden' on twitter
                     $tweets = $connection->get('statuses/user_timeline', ['count' => 200, 'exclude_replies' => true, 'screen_name' => 'snowden', 'include_rts' => false]);
                     $totalTweets[] = $tweets;
                     $page = 0;
                     for ($count = 200; $count < 500; $count += 200) {
                         $max = count($totalTweets[$page]) - 1;
                         $tweets = $connection->get('statuses/user_timeline', ['count' => 200, 'exclude_replies' => true, 'max_id' => $totalTweets[$page][$max]->id_str, 'screen_name' => 'snowden', 'include_rts' => false]);
                         $totalTweets[] = $tweets;
                         $page += 1;
                     }
                     return $totalTweets;
                 }
             }
         }
     }
 }
开发者ID:jedelhu,项目名称:socialpack,代码行数:46,代码来源:SocialpackController.php

示例7: index

 function index()
 {
     //$this->get_localhost();
     $tokens = array("consumer_key" => "nI5mbQJ90srwBDIPGBrAIUphJ", "consumer_key_secret" => "EMubqMnZNuIIy6echinNa7uXd3xM67jfyZ6SmPiiXkUUdcCApb", "access_token" => "38682087-3RjO1RdEQpAmnt5rzwhiFiWKsCACQKY1zHfPYpAkF", "access_token_secret" => "gl4WAIpTRSFnld6kJxaD68pcn9IyEEJzGQO4z7r3TR1zm");
     $connection = new TwitterOAuth($tokens["consumer_key"], $tokens["consumer_key_secret"], $tokens["access_token"], $tokens["access_token_secret"]);
     $data = $connection->post("oauth2/token");
     $timeline = $connection->get("statuses/user_timeline", array("screen_name" => "aldouswright"));
     echo "<pre>";
     echo "<ul>";
     foreach ($timeline as $tweet) {
         echo "<li>" . $tweet->text . "</li>";
     }
     echo "</ul>";
     print_r($timeline);
     echo "</pre>";
     die;
 }
开发者ID:patrickchiuco,项目名称:restfulapi,代码行数:17,代码来源:Client.php

示例8: postTwitter

 public function postTwitter($array)
 {
     $optionAppTwitter = get_option('twfc_app_twitter');
     // realiza a conexão com o twiiter
     $connection = new TwitterOAuth($optionAppTwitter['twitterconsumer'], $optionAppTwitter['twitterconsumersecret'], $optionAppTwitter['twitteraccesstoken'], $optionAppTwitter['twitteraccesstokensecret']);
     $content = $connection->get("account/verify_credentials");
     if (isset($content)) {
         if ($array['imagem']) {
             $media = $connection->upload('media/upload', array('media' => $array['imagem']));
             $parameters = array('status' => $array['titulo'], 'media_ids' => $media1->media_id_string);
         } else {
             $parameters = array('status' => $array['titulo']);
         }
         $result = $connection->post('statuses/update', $parameters);
         return $result;
     }
 }
开发者ID:reinaldorodrigues,项目名称:twfc-post,代码行数:17,代码来源:twfctwitter.php

示例9: postTweet

 /**
  * ツイートを投稿する関数
  *
  * @param   object  $connection     投稿に使用する TwitterOAuth のインスタンス
  * @param   array   $param          Twitter に送信するパラメータ
  * @param   int     $retryLimit     最大再試行回数
  * @return  bool    投稿に成功すれば true、失敗すれば false
  */
 public static function postTweet(TwitterOAuth $connection, array $param, $retryLimit = 3)
 {
     Log::info("Twitter に tweet を POST します:");
     Log::info($param);
     for ($retry = 0; $retry < $retryLimit; ++$retry) {
         if ($retry > 0) {
             sleep(1);
         }
         $result = $connection->post('statuses/update', $param);
         if (is_object($result) && isset($result->id_str) && isset($result->text)) {
             Log::success("Tweet を投稿しました");
             Log::success(['id' => $result->id_str, 'text' => $result->text]);
             return true;
         }
         Log::warning("Tweet の投稿に失敗しました");
     }
     Log::error("Tweet を投稿できませんでした");
     Log::error($param);
     return false;
 }
开发者ID:nonoliri,项目名称:chomado_bot,代码行数:28,代码来源:TwitterUtil.php

示例10: main

 /**
  * @return void
  * @throws \BuildException
  */
 public function main()
 {
     $twitterConsumerKey = $this->getProjectProperty('twitter.consumer.key');
     $twitterConsumerSecret = $this->getProjectProperty('twitter.consumer.secret');
     $twitterAccessToken = $this->getProjectProperty('twitter.access.token');
     $twitterAccessTokenSecret = $this->getProjectProperty('twitter.access.token.secret');
     $projectVersion = $this->getProjectProperty('project.version');
     $projectVendor = $this->getProjectProperty('project.vendor');
     $projectName = $this->getProjectProperty('project.name');
     $tweet = "{$projectVendor}/{$projectName} {$projectVersion}";
     if (!empty($this->projectUrl)) {
         $tweet .= ' | ' . $this->projectUrl;
     }
     if (!empty($this->projectTags)) {
         $tweet .= ' | #' . implode(", #", array_filter(array_map("trim", explode(",", $this->projectTags))));
     }
     $this->log('this tweet will be sent');
     $this->log($tweet);
     try {
         $request = new \InputRequest('do you wanna send this tweet? [y/n]:');
         $this->project->getInputHandler()->handleInput($request);
         $answer = trim($request->getInput());
     } catch (\IOException $e) {
         throw new \BuildException("prompt failed. reason: " . $e->getMessage());
     }
     $answer = empty($answer) ? 'n' : substr(strtolower($answer), 0, 1);
     if ($answer == 'n') {
         $this->log('skipped tweeting to twitter');
         return;
     }
     $this->log('tweet sending ...');
     try {
         $connection = new TwitterOAuth($twitterConsumerKey, $twitterConsumerSecret, $twitterAccessToken, $twitterAccessTokenSecret);
         $connection->post("statuses/update", array("status" => $tweet));
     } catch (\Exception $e) {
         throw new \BuildException("sending failed. reason: " . $e->getMessage());
     }
     $this->log('tweet was send');
 }
开发者ID:elnebuloso,项目名称:phing-commons,代码行数:43,代码来源:TweetPackageTask.php

示例11: TwitterOAuth

<?php

$root = __DIR__;
$loader = (require $root . '/vendor/autoload.php');
$loader->add('', $root . '/classes/');
$pixie = new \App\Pixie();
$pixie->bootstrap($root);
use Abraham\TwitterOAuth\TwitterOAuth;
$api = new TwitterOAuth($pixie->config->get('twitter.consumer_key'), $pixie->config->get('twitter.consumer_secret'), $argv[1], $argv[2]);
$devs = $pixie->config->get('devs');
file_put_contents($root . '/log.txt', "started\n", FILE_APPEND);
foreach ($devs as $dev) {
    $res = $api->post('friendships/create', array('screen_name' => $dev['twitter']));
}
file_put_contents($root . '/log.txt', "finished\n", FILE_APPEND);
开发者ID:roman-tsiupa,项目名称:phprockstars.com,代码行数:15,代码来源:follow.php

示例12: testPostStatusesDestroy

 /**
  * @depends testPostStatusesUpdateUtf8
  */
 public function testPostStatusesDestroy($status)
 {
     $this->twitter->post('statuses/destroy/' . $status->id_str);
     $this->assertEquals(200, $this->twitter->getLastHttpCode());
 }
开发者ID:alexxnotfound,项目名称:twitter_bot,代码行数:8,代码来源:TwitterOAuthTest.php

示例13: TwitterOAuth

<html>
  <head>
    <title>Tweet</title>
  </head>
  <body>
    <pre>
      <?php 
session_start();
require "twitteroauth/autoload.php";
use Abraham\TwitterOAuth\TwitterOAuth;
require "initialize.php";
#APIにアクセスするためのアクセストークンを用いて$connectionを作成
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
#"Hello,world!"とツイートする、$resultにはbool型で実行結果が出力される
$result = $connection->post('statuses/update', array('status' => "Hello,world!"));
if ($result) {
    print "success!";
} else {
    print "failed...";
}
#ログインしたアカウントのプロフィールの取得、出力
var_dump($connection->get("account/verify_credentials"));
?>
    </pre>
  </body>
</html>
开发者ID:ryoueno,项目名称:RankChannel,代码行数:26,代码来源:tweet.php

示例14: unset

						
						echo $crawling_friends_url;
						echo '</p>';
					}
*/
?>
			</div>
		</div>

		<div class="sidebar right">
			<ul>
				<?php 
//外部ファイルにしていきたい
//リツイートされたか
if (isset($_POST['retweet'])) {
    $tw->post('statuses/retweet/' . $_POST['retweet']);
    unset($_POST['retweet']);
}
if (isset($_POST['favo'])) {
    $tw->post('favorites/create', ['id' => $_POST['favo']]);
    unset($_POST['favo']);
}
//タイムラインの識別
if (isset($_POST['timeline'])) {
    if ($_POST['timeline'] == 'home') {
        $TimeLine = 'home';
    } else {
        $TimeLine = 'user';
    }
} else {
    $TimeLine = 'user';
开发者ID:l-a-donut,项目名称:TwitterApps_001,代码行数:30,代码来源:statistical.php

示例15: header

require_once __DIR__ . '/controller/config.php';
require_once __DIR__ . '/controller/Twitterlogin.php';
$twitterLogin = new MyApp\TwitterLogin();
use Abraham\TwitterOAuth\TwitterOAuth;
if ($twitterLogin->isLoggedIn()) {
    $me = $_SESSION['me'];
    MyApp\Token::create();
} else {
    header('Location: http://' . $_SERVER['HTTP_HOST'] . '/devAid-v1.2/index.php');
    exit;
}
$screen_name = $me->tw_screen_name;
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $me->tw_access_token, $me->tw_access_token_secret);
// ユーザIDでフォローする
$connection->post('friendships/create', ['screen_name' => 'hatebu']);
// ユーザ名でユーザ情報を取得
$user_info = $connection->get('users/show', ['screen_name' => $screen_name]);
$user_name = $user_info->name;
$user_id = $user_info->screen_name;
$user_img = $user_info->profile_image_url_https;
$user_follows = $user_info->friends_count;
$user_followers = $user_info->followers_count;
?>
<!DOCTYPE html>
<html lang="en"> 
    <head>
        <title>両思いったー</title>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
开发者ID:johnmanjiro,项目名称:first_app,代码行数:30,代码来源:mypage.php


注:本文中的Abraham\TwitterOAuth\TwitterOAuth::post方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。