本文整理汇总了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";
}
}
示例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);
}
示例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";
}
}
示例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));
}
}
示例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";
}
}
示例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;
}
}
}
}
}
示例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;
}
示例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;
}
}
示例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;
}
示例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');
}
示例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);
示例12: testPostStatusesDestroy
/**
* @depends testPostStatusesUpdateUtf8
*/
public function testPostStatusesDestroy($status)
{
$this->twitter->post('statuses/destroy/' . $status->id_str);
$this->assertEquals(200, $this->twitter->getLastHttpCode());
}
示例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>
示例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';
示例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">