- 浏览: 13731084 次
- 性别:
- 来自: 洛杉矶
文章分类
- 全部博客 (1994)
- Php / Pear / Mysql / Node.js (378)
- Javascript /Jquery / Bootstrap / Web (435)
- Phone / IOS / Objective-C / Swift (137)
- Ubuntu / Mac / Github / Aptana / Nginx / Shell / Linux (335)
- Perl / Koha / Ruby / Markdown (8)
- Java / Jsp (12)
- Python 2 / Wxpython (25)
- Codeigniter / CakePHP (32)
- Div / Css / XML / HTML5 (179)
- WP / Joomla! / Magento / Shopify / Drupal / Moodle / Zimbra (275)
- Apache / VPN / Software (31)
- AS3.0/2.0 / Flex / Flash (45)
- Smarty (6)
- SEO (24)
- Google / Facebook / Pinterest / SNS (80)
- Tools (22)
最新评论
-
1455975567:
xuezhongyu01 写道wocan23 写道我想问下那个 ...
Mysql: LBS实现查找附近的人 (两经纬度之间的距离) -
xuezhongyu01:
wocan23 写道我想问下那个111.1是怎么得来的我也看不 ...
Mysql: LBS实现查找附近的人 (两经纬度之间的距离) -
18335864773:
试试 pageoffice 在线打开 PDF 文件吧. pag ...
jquery在线预览PDF文件,打开PDF文件 -
青春依旧:
opacity: 0.5; 个人喜欢这种方式!关于其他css特 ...
css透明度的设置 (兼容所有浏览器) -
July01:
推荐用StratoIO打印控件,浏览器和系统的兼容性都很好,而 ...
搞定网页打印自动分页问题
Twitter is awesome! Using the simple script below you, you can post updates to twitter. Don’t forget to add your username, password and message below.
<?php function tweetThis($strUsername = '', $strPassword = '', $strMessage = '') { if (function_exists('curl_init')) { $twitterUsername = trim($strUsername); $twitterPassword = trim($strPassword); if(strlen($strMessage) > 140) { $strMessage = substr($strMessage, 0, 140); } $twitterStatus = htmlentities(trim(strip_tags($strMessage))); if (!empty($twitterUsername) && !empty($twitterPassword) && !empty($twitterStatus)) { $strTweetUrl = 'http://www.twitter.com/statuses/update.xml'; $objCurlHandle = curl_init(); curl_setopt($objCurlHandle, CURLOPT_URL, "$strTweetUrl"); curl_setopt($objCurlHandle, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($objCurlHandle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($objCurlHandle, CURLOPT_POST, 1); curl_setopt($objCurlHandle, CURLOPT_POSTFIELDS, "status=$twitterStatus"); curl_setopt($objCurlHandle, CURLOPT_USERPWD, "$twitterUsername:$twitterPassword"); $result = curl_exec($objCurlHandle); $arrResult = curl_getinfo($objCurlHandle); if ($arrResult['http_code'] == 200) { echo 'Your Tweet has been posted'; } else { echo 'Could not post your Tweet to Twitter.'; } curl_close($objCurlHandle); } else { echo('Missing required information to submit your Tweet.'); } } else { echo('Curl Extension is not installed.'); } } ?>
<?php // Send a Tweet to your Twitter account. tweetThis('my_user_name', 'my_password', 'my_tweet_message'); ?>
或者
<?php /////////////////////////////////////////// // // twitterPHP // version 0.1 // By David Billingham // david [at] slawcup [dot] com // http://twitter.slawcup.com/twitter.class.phps // // // Example 1: // // $t= new twitter(); // $res = $t->publicTimeline(); // if($res===false){ // echo "ERROR<hr/>"; // echo "<pre>"; // print_r($t->responseInfo); // echo "</pre>"; // }else{ // echo "SUCCESS<hr/>"; // echo "<pre>"; // print_r($res); // echo "</pre>"; // } // // // Example 2: // // $t= new twitter(); // $t->username='username'; // $t->password='password'; // $res = $t->update('i am testing twitter.class.php'); // if($res===false){ // echo "ERROR<hr/>"; // echo "<pre>"; // print_r($t->responseInfo); // echo "</pre>"; // }else{ // echo "SUCCESS<hr/>Status Posted"; // } // // ////////////////////////////////////////// class twitter{ var $username=''; var $password=''; var $user_agent=''; /////////////// // // I don't know if these headers have become standards yet // but I would suggest using them. // more discussion here. // http://tinyurl.com/3xtx66 // /////////////// var $headers=array('X-Twitter-Client: ', 'X-Twitter-Client-Version: ', 'X-Twitter-Client-URL: '); var $responseInfo=array(); function twitter(){} ///////////////////////////////////////// // // Twitter API calls // // $this->update($status) // $this->publicTimeline($sinceid=false) // $this->friendsTimeline($id=false,$since=false) // $this->userTimeline($id=false,$count=20,$since=false) // $this->showStatus($id) // $this->friends($id=false) // $this->followers() // $this->featured() // $this->showUser($id) // $this->directMessages($since=false) // $this->sendDirectMessage($user,$text) // // If SimpleXMLElement exists the results will be returned as a SimpleXMLElement // otherwise the raw XML will be returned for a successful request. If the request // fails a FALSE will be returned. // // ///////////////////////////////////////// // Updates the authenticating user's status. // Requires the status parameter specified below. // // status. (string) Required. The text of your status update. Must not be // more than 160 characters and should not be // more than 140 characters to ensure optimal display. // function update($status){ $request = 'http://twitter.com/statuses/update.xml'; $postargs = 'status='.urlencode($status); return $this->process($request,$postargs); } // Returns the 20 most recent statuses from non-protected users who have // set a custom user icon. Does not require authentication. // // sinceid. (int) Optional. Returns only public statuses with an ID greater // than (that is, more recent than) the specified ID. // function publicTimeline($sinceid=false){ $qs=''; if($sinceid!==false) $qs='?since_id='.intval($sinceid); $request = 'http://twitter.com/statuses/public_timeline.xml'.$qs; return $this->process($request); } // Returns the 20 most recent statuses posted in the last 24 hours from the // authenticating user and that user's friends. It's also possible to request // another user's friends_timeline via the id parameter below. // // id. (string OR int) Optional. Specifies the ID or screen name of the user for whom // to return the friends_timeline. (set to false if you // want to use authenticated user). // since. (HTTP-formatted date) Optional. Narrows the returned results to just those // statuses created after the specified date. // function friendsTimeline($id=false,$since=false){ $qs=''; if($since!==false) $qs='?since='.urlencode($since); if($id===false) $request = 'http://twitter.com/statuses/friends_timeline.xml'.$qs; else $request = 'http://twitter.com/statuses/friends_timeline/'.urlencode($id).'.xml'.$qs; return $this->process($request); } // Returns the 20 most recent statuses posted in the last 24 hours from the // authenticating user. It's also possible to request another user's timeline // via the id parameter below. // // id. (string OR int) Optional. Specifies the ID or screen name of the user for whom // to return the user_timeline. // count. (int) Optional. Specifies the number of statuses to retrieve. May not be // greater than 20 for performance purposes. // since. (HTTP-formatted date) Optional. Narrows the returned results to just those // statuses created after the specified date. // function userTimeline($id=false,$count=20,$since=false){ $qs='?count='.intval($count); if($since!==false) $qs .= '&since='.urlencode($since); if($id===false) $request = 'http://twitter.com/statuses/user_timeline.xml'.$qs; else $request = 'http://twitter.com/statuses/user_timeline/'.urlencode($id).'.xml'.$qs; return $this->process($request); } // Returns a single status, specified by the id parameter below. The status's author // will be returned inline. // // id. (int) Required. Returns status of the specified ID. // function showStatus($id){ $request = 'http://twitter.com/statuses/show/'.intval($id).'.xml'; return $this->process($request); } // Returns the authenticating user's friends, each with current status inline. It's // also possible to request another user's friends list via the id parameter below. // // id. (string OR int) Optional. The ID or screen name of the user for whom to request // a list of friends. // function friends($id=false){ if($id===false) $request = 'http://twitter.com/statuses/friends.xml'; else $request = 'http://twitter.com/statuses/friends/'.urlencode($id).'.xml'; return $this->process($request); } // Returns the authenticating user's followers, each with current status inline. // function followers(){ $request = 'http://twitter.com/statuses/followers.xml'; return $this->process($request); } // Returns a list of the users currently featured on the site with their current statuses inline. function featured(){ $request = 'http://twitter.com/statuses/featured.xml'; return $this->process($request); } // Returns extended information of a given user, specified by ID or screen name as per the required // id parameter below. This information includes design settings, so third party developers can theme // their widgets according to a given user's preferences. // // id. (string OR int) Required. The ID or screen name of a user. // function showUser($id){ $request = 'http://twitter.com/users/show/'.urlencode($id).'.xml'; return $this->process($request); } // Returns a list of the direct messages sent to the authenticating user. // // since. (HTTP-formatted date) Optional. Narrows the resulting list of direct messages to just those // sent after the specified date. // function directMessages($since=false){ $qs=''; if($since!==false) $qs='?since='.urlencode($since); $request = 'http://twitter.com/direct_messages.xml'.$qs; return $this->process($request); } // Sends a new direct message to the specified user from the authenticating user. Requires both the user // and text parameters below. // // user. (string OR int) Required. The ID or screen name of the recipient user. // text. (string) Required. The text of your direct message. Be sure to URL encode as necessary, and keep // it under 140 characters. // function sendDirectMessage($user,$text){ $request = 'http://twitter.com/direct_messages/new.xml'; $postargs = 'user='.urlencode($user).'&text='.urlencode($text); return $this->process($request,$postargs); } // internal function where all the juicy curl fun takes place // this should not be called by anything external unless you are // doing something else completely then knock youself out. function process($url,$postargs=false){ $ch = curl_init($url); if($postargs !== false){ curl_setopt ($ch, CURLOPT_POST, true); curl_setopt ($ch, CURLOPT_POSTFIELDS, $postargs); } if($this->username !== false && $this->password !== false) curl_setopt($ch, CURLOPT_USERPWD, $this->username.':'.$this->password); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_NOBODY, 0); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_USERAGENT, $this->user_agent); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers); $response = curl_exec($ch); $this->responseInfo=curl_getinfo($ch); curl_close($ch); if(intval($this->responseInfo['http_code'])==200){ if(class_exists('SimpleXMLElement')){ $xml = new SimpleXMLElement($response); return $xml; }else{ return $response; } }else{ return false; } } } ?>
- update-twitter-php.zip (3.1 KB)
- 下载次数: 2
发表评论
-
PHP: 在类(class)中加载动态函数, 变量函数或半变量函数 variable function/method
2016-09-03 07:54 7171最终实例在下方 以前 ... -
MySQL入门 (七) : 储存引擎与资料型态
2016-09-03 07:49 45531 表格与储存引擎 表格(table)是资料库中用来储存 ... -
MySQL入门 (六) : 字元集与资料库
2016-09-03 07:47 45661 Character Set与Collation 任何 ... -
MySQL入门 (五) : CRUD 与资料维护
2016-09-03 07:46 54811 取得表格资讯 1.1 DESCRIBE指令 「 ... -
MySQL入门 (四) : JOIN 与UNION 查询
2016-09-03 07:42 45001 使用多个表格 在「world」资料库的「countr ... -
PHP: 关键字global 和 超全局变量$GLOBALS的用法、解释、区别
2016-08-31 12:07 5039$GLOBALS 是一个关联数组,每一个变量为一个 ... -
MySQL入门 (三) : 运算式与函式
2016-08-31 12:01 4383运算式(expressions)已经 ... -
MySQL入门 (二) : SELECT 基础查询
2016-08-31 11:56 46811 查询资料前的基本概念 1.1 表格、纪录 ... -
MySQL入门 (一) : 资料库概论与MySQL的安装
2016-08-31 11:51 44571. 储存与管理资料 储存与管理资料一直是资讯应用上最基本 ... -
MySQL入门 (九) : 子查询 Subquery
2016-08-30 02:26 44471 一个叙述中的查询叙述 子查询(subquery)是一 ... -
PHP: 用readonly取代disabled来获取input值 submit a disabled input in a form could not ge
2016-08-30 02:21 2706The form is like below; <f ... -
PHP7革新与性能优化
2016-08-30 02:20 2146有幸参与2015年的PHP技 ... -
Mysql: 图解 inner join、left join、right join、full outer join、union、union all的区别
2016-08-18 06:03 3122对于SQL的Join,在学习起来可能是比较乱的。我们知道, ... -
Comet 反Ajax: 基于jQuery与PHP实现Ajax长轮询(LongPoll)
2016-08-18 06:00 1377传统的AJAX轮询方式,客服端以用户定义的时间间隔去服务器上 ... -
PHP:ServerPush (Comet推送) 技术的探讨
2016-08-18 05:58 1039PHP中Push(推送)技术的探讨 [http://vi ... -
PHP: 手把手编写自己的 MVC 框架实例教程
2016-08-16 05:33 18131 什么是MVC MVC模式(Model-View-Con ... -
PHP5: mysqli 插入, 查询, 更新和删除 Insert Update Delete Using mysqli (CRUD)
2016-07-29 12:55 1747原文: PHP5: mysqli 插入, 查询, 更新 ... -
MongoDB 教程索引 (附有视频)
2016-07-27 10:54 736MongoDB 教程索引 MongoDB 教程一: ... -
Node.js 模块之Nimble流程控制
2016-07-18 12:59 1081NodeJS异步的特性有时候 ... -
Node.js web应用模块之Supervisor
2016-07-18 12:56 2327在开发或调试Node.js应 ...
相关推荐
SG Patcher - Update your game easily In-App v1.12.2
$post_tweet = $connection->post('statuses/update', ['status' => $status]); echo "新推文ID: " . $post_tweet->id_str; ``` 此外,还可以利用Twitter API进行搜索、获取时间线、关注用户、回复推文等操作。每个...
StatusUpdate status = new StatusUpdate("Hello, Twitter API!"); twitter.updateStatus(status); System.out.println("成功发送了一条推文: " + status.getText()); } catch (TwitterException e) { e....
3. **构造Tweet对象**:使用Twitter4J,你可以创建一个`StatusUpdate`对象,设置其`text`属性为包含URL的文本,然后使用`附带Media`的方法添加之前上传的图片Media ID。例如: ```java StatusUpdate statusUpdate ...
3. 发布推文:通过`Twitter`实例的`updateStatus()`方法,可以发布新的推文。 4. 获取时间线:调用`getHomeTimeline()`或`getUserTimeline()`方法,可以获取用户的最新推文或指定用户的推文。 5. 搜索推文:利用`...
- 发布推文:使用`Twitter.updateStatus()`方法发送新的推文。 - 获取推文:通过`Twitter.getHomeTimeline()`获取用户的时间线,或使用`Twitter.getUserTimeline()`获取指定用户的时间线。 4. **用户管理**: - ...
Enfocus_PitStop_Pro_10_Update2_Patch Acrobat 的插件,可以去除水印等 如果你用了PP10,请更新到update2 在论坛上卖很贵了,我从国外网站上找来分享给大家。 使用方法见压缩包内文本文件。
Status status = twitter.updateStatus("Hello, Twitter4J!"); System.out.println("Successfully updated the status to [" + status.getText() + "]."); } catch (TwitterException e) { e.printStackTrace(); ...
本教程将指导你如何使用jQuery、PHP和MySQL构建一个类似Twitter的微型博客站点。首先,我们要了解这个项目的基本架构和涉及的技术。 **jQuery** 是一种广泛使用的JavaScript库,它简化了DOM操作、事件处理、动画...
修复yii2 在php7.1与php7.2兼容包 增加yii2 for update查询 forupdate 例子: ModelMember::find()->where(...=',ModelMember::TABLE_USER.'.status', MemberDataDao::ATTR_STATUS_DELETE])->forUpdate()->one();
- 当用户点击分享按钮时,应用会调用`twitter4j`库的方法,例如`Twitter.getInstance().updateStatus()`,传入用户输入的文字,发送一条新的推文。 6. **权限处理**: - 在AndroidManifest.xml中,需要声明网络...
在Windows操作系统中,Windows Update是一项重要的服务,它负责为系统提供最新的安全补丁、功能更新以及驱动程序。然而,有时Windows Update可能会遇到问题,导致更新无法正常进行或更新过程失败。在这种情况下,...
C编程在运行时更新状态栏信息C Programming in the run-time information update status bar
Merge 更新法是 Oracle 特有的语句,语法为:`MERGE INTO table_name alias1 USING (table|view|sub_query) alias2 ON (join condition) WHEN MATCHED THEN UPDATE table_name SET ... WHEN NOT MATCHED THEN INSERT...
STK-Disk913x-Techinical Update-Using Licensed Internal Code Revi
STK-Disk913x-Technical Update -Using Licensed Internal Code Revi