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


PHP TwitterOAuth::upload方法代码示例

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


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

示例1: array

			$status ='yapyzal donate fixed checking -'.$short;
			$tweet = $connection->post('statuses/update', array('status' => $status));*/
//$filename = "image.jpg";
//$handle = fopen($filename, "rb");
//$image = fread($handle, filesize($filename));
//fclose($handle);
//$params = array('media[]' => "{$image};type=image/jpeg;filename={$filename}" ,
//   'status'   => 'my status');
//$response =$connection->post('statuses/update_with_media', $params,true,true);
/*$oauth_token=$access_token['oauth_token'];
		$oauth_token_secret=$access_token['oauth_token_secret'];
		echo $oauth_token;
		echo $oauth_token_secret;*/
$status = 'yapyzal donate fixed checkingdddrr';
//$tweet = $connection->post('statuses/update', array('status' => $status));
$connection->upload('statuses/update_with_media', array('media[]' => "ganesh.jpg", 'status' => "{$status}"));
/*$image = '2.bp.blogspot.com/-gHMuO_huw0s/UjNEQl-fL_I/AAAAAAAAAWQ/HhqGo4MskrE/s320/srinu.jpg';

    $code = $connection->request( 'POST','https://upload.twitter.com/1.1/statuses/update_with_media.json',
       array(
            'media[]'  => "@{$image};type=image/jpeg;filename={$filename}",
            'status'   => 'hi this is sample',
       ),
        true, // use auth
        true  // multipart
    );

    if ($code == 200){
       tmhUtilities::pr(json_decode($connection->response['response']));
    }else{
       tmhUtilities::pr($connection->response['response']);
开发者ID:namizich,项目名称:BirdMachine,代码行数:31,代码来源:index.php

示例2: tweet

 /**
  * Post a status update to Twitter
  * @param int      $item_id
  */
 public function tweet($item_id)
 {
     access::verify_csrf();
     $item = ORM::factory("item", $item_id);
     $form = twitter::get_tweet_form($item);
     if ($form->validate()) {
         $item_url = url::abs_site($item->relative_url_cache);
         $user = $this->_get_twitter_user(identity::active_user()->id);
         $consumer_key = module::get_var("twitter", "consumer_key");
         $consumer_secret = module::get_var("twitter", "consumer_secret");
         require_once MODPATH . "twitter/vendor/twitteroauth/twitteroauth.php";
         $connection = new TwitterOAuth($consumer_key, $consumer_secret, $user->oauth_token, $user->oauth_token_secret);
         $message = $form->twitter_message->tweet->value;
         $attach_image = $form->twitter_message->attach_image->value;
         if ($attach_image == 1) {
             $filename = APPPATH . "../var/resizes/" . $item->relative_path_cache;
             $handle = fopen($filename, "rb");
             $image = fread($handle, filesize($filename));
             fclose($handle);
             $response = $connection->upload('statuses/update_with_media', array('media[]' => "{$image};type=image/jpeg;filename={$filename}", 'status' => $message));
         } else {
             $response = $connection->post('statuses/update', array('status' => $message));
         }
         if (200 == $connection->http_code) {
             message::success(t("Tweet sent!"));
             json::reply(array("result" => "success", "location" => $item->url()));
         } else {
             message::error(t("Unable to send, your Tweet has been saved. Please try again later: %http_code, %response_error", array("http_code" => $connection->http_code, "response_error" => $response->error)));
             log::error("content", "Twitter", t("Unable to send tweet: %http_code", array("http_code" => $connection->http_code)));
             json::reply(array("result" => "success", "location" => $item->url()));
         }
         $tweet->item_id = $item_id;
         !empty($response->id) ? $tweet->twitter_id = $response->id : ($tweet->twitter_id = NULL);
         $tweet->tweet = $message;
         $tweet->id = $form->twitter_message->tweet_id->value;
         $this->_save_tweet($tweet);
     } else {
         json::reply(array("result" => "error", "html" => (string) $form));
     }
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:44,代码来源:twitter.php

示例3: tweet_with_image

 /**
  * Used to upload image into Twitter
  * (attachment to text)
  *
  * @access public
  * @param $image_name
  * @param $status
  * @return mixed
  */
 public function tweet_with_image($status, $image_name)
 {
     $image_path = dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/public/uploads/' . $this->_user_id . '/' . $image_name;
     $connection = new TwitterOAuth($this->_config['consumer_key'], $this->_config['consumer_secret'], $this->_token['token1'], $this->_token['token2']);
     $tweet = $connection->upload('statuses/update_with_media', array('media[]' => '@' . $image_path, 'status' => $status));
     return $tweet;
 }
开发者ID:andrewkrug,项目名称:repucaution,代码行数:16,代码来源:Twitter.php


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