<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Horn Network &#187; curl</title>
	<atom:link href="http://klcin.tw/net/tag/curl/feed" rel="self" type="application/rss+xml" />
	<link>http://klcin.tw/net</link>
	<description>Horn Network (.NET, ASP.NET, C#, VB.NET, JavaScript, Ubuntu, Android ...)</description>
	<lastBuildDate>Fri, 04 Mar 2011 07:25:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>[PHP]PO3 一次幫你把訊息PO到3個地方（Buboo,Plurk,Twitter）！</title>
		<link>http://klcin.tw/net/po3</link>
		<comments>http://klcin.tw/net/po3#comments</comments>
		<pubDate>Sat, 05 Jul 2008 09:59:50 +0000</pubDate>
		<dc:creator>klcintw</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[PO3]]></category>
		<category><![CDATA[Buboo]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[Plurk]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[xampp]]></category>

		<guid isPermaLink="false">http://klcin.tw/net/?p=7</guid>
		<description><![CDATA[到處看得到 web 2.0 的應用，另稱微網誌的類twitter線上服務更是多如繁星（誤）。 除了國外開山始祖twitter之外，台灣的buboo更是匯聚許多人親土親同文同種的朋友，再加上近來聲勢漸漲號稱「加上時間軸」的plurk，各有各的特色各有各的擁護者。 其實很多人應該都會在不同的服務申請帳號，只是要發一則訊息卻要登入各個服務的網頁實在麻煩。 雖然有像Hellotxt這種可以幫你一次更新許多不同的社交網站，但是，有飯否卻沒有巴布！ 其實，從技術的角度來看buboo,plurk,twitter三者還滿相似的，只是plurk目前並沒有公開它的API。 從網路上找到可以用PHP發訊息到twitter和plurk的套件，另外改寫成可以發到buboo然後再整合成統一的畫面。線上展示。 Jonathan 的 BLOG ? 整合 Twitter 的 php 寫法 rlplurkapi &#8211; Google Code – 這是非官方的Plurk API。Category:Reference &#8211; Plurk API Wiki發現更簡單的方法也是用curl：Charl van Niekerk » Blog: Plurk PHP Post Script 注意：PHP必須能夠使用 curl 功能，buboo和twitter都會用到。 twitter 發文函式： // 發文到twitter function post_twitter($uid, $pwd, $msg) { $curl_handle = curl_init(); curl_setopt($curl_handle, CURLOPT_URL, &#039;http://twitter.com/statuses/update.xml&#039;); [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://klcin.tw/ap/po3/" target="_blank"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" title="PO3" src="http://klcin.tw/net/images/PHPPOBubooPlurkTwitter_EF99/snap006.png" border="0" alt="PO3" width="304" align="right" /></a> 到處看得到 web 2.0 的應用，另稱微網誌的類twitter線上服務更是多如繁星（誤）。<br />
除了國外開山始祖<a href="http://twitter.com" target="_blank">twitter</a>之外，台灣的<a href="http://buboo.tw/" target="_blank">buboo</a>更是匯聚許多人親土親同文同種的朋友，再加上近來聲勢漸漲號稱「加上時間軸」的<a href="http://www.plurk.com" target="_blank">plurk</a>，各有各的特色各有各的擁護者。</p>
<p>其實很多人應該都會在不同的服務申請帳號，只是要發一則訊息卻要登入各個服務的網頁實在麻煩。<br />
雖然有像<a href="http://hellotxt.com/" target="_blank">Hellotxt</a>這種可以幫你一次更新許多不同的社交網站，但是，有<a href="http://fanfou.com" target="_blank">飯否</a>卻沒有巴布！</p>
<p><span id="more-7"></span></p>
<p>其實，從技術的角度來看buboo,plurk,twitter三者還滿相似的，只是plurk目前並沒有公開它的API。<br />
從網路上找到可以用PHP發訊息到twitter和plurk的套件，另外改寫成可以發到buboo然後再整合成統一的畫面。<a href="http://klcin.tw/ap/po3/" target="_blank">線上展示</a>。</p>
<ul>
<li><a href="http://blog.ichiayi.com/2007/10/29/%E6%95%B4%E5%90%88-twitter-%E7%9A%84-php-%E5%AF%AB%E6%B3%95/" target="_blank">Jonathan 的 BLOG ? 整合 Twitter 的 php 寫法</a></li>
<li><a href="http://code.google.com/p/rlplurkapi/" target="_blank">rlplurkapi &#8211; Google Code</a> – 這是非官方的Plurk API。<a href="http://plurkwiki.badchemicals.net/index.php?title=Category:Reference" target="_blank">Category:Reference &#8211; Plurk API Wiki</a><br /><del datetime="2008-12-05T04:15:00+00:00">發現更簡單的方法也是用curl：<a href="http://blog.charlvn.za.net/2008/06/plurk.html" target="_blank">Charl van Niekerk » Blog: Plurk PHP Post Script</a></del></li>
</ul>
<p><strong>注意：</strong>PHP必須能夠使用 <a href="http://curl.haxx.se/" target="_blank">curl</a> 功能，buboo和twitter都會用到。</p>
<p><strong>twitter 發文函式：</strong></p>
<pre class="brush: php">// 發文到twitter
function post_twitter($uid, $pwd, $msg) {
	$curl_handle = curl_init();
	curl_setopt($curl_handle, CURLOPT_URL, &#039;http://twitter.com/statuses/update.xml&#039;);
	curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
	curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($curl_handle, CURLOPT_POST, 1);
	curl_setopt($curl_handle, CURLOPT_POSTFIELDS, &quot;status=$msg&quot;);
	curl_setopt($curl_handle, CURLOPT_USERPWD, &quot;$uid:$pwd&quot;);
	$buffer = curl_exec($curl_handle);
	curl_close($curl_handle);
	// 檢查結果
	return chkresult($buffer,&#039;&lt;text&gt;&#039;);
}</pre>
<p><strong>buboo 發文函式：</strong></p>
<pre class="brush: php">// 發文到buboo
function post_bubbo($uid, $pwd, $msg) {
	$curl_handle = curl_init();
	curl_setopt($curl_handle, CURLOPT_URL, &#039;http://api.buboo.tw/update.xml&#039;); //改
	curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
	curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($curl_handle, CURLOPT_POST, 1);
	curl_setopt($curl_handle, CURLOPT_POSTFIELDS, &quot;message=$msg&quot;); //改
	curl_setopt($curl_handle, CURLOPT_USERPWD, &quot;$uid:$pwd&quot;);
	$buffer = curl_exec($curl_handle);
	curl_close($curl_handle);
	// 檢查結果
	return chkresult($buffer,&#039;&lt;ok&gt;1&lt;/ok&gt;&#039;);
}</pre>
<p><strong>plurk 發文函式：</strong></p>
<pre class="brush: php">// 發文到plurk
// 2008/07/19 改
// $nick_name 是顯示名稱，如 klcintw
// $uid 是使用者代號，藏在網頁原始碼裡，如：&quot;user_id&quot;: 30140
function post_plurk($nick_name, $pwd, $uid, $msg) {
	$curl_handle = curl_init();
	curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
	// 認證
	curl_setopt($curl_handle, CURLOPT_COOKIEJAR, &#039;cookie.txt&#039;);
	curl_setopt($curl_handle, CURLOPT_COOKIEFILE, &#039;cookie.txt&#039;);
	curl_setopt($curl_handle, CURLOPT_URL, &#039;http://www.plurk.com/Users/login&#039;);
	curl_setopt($curl_handle, CURLOPT_POSTFIELDS, &quot;nick_name=$nick_name&amp;password=$pwd&quot;);
	curl_exec($curl_handle);
	// 發文
	curl_setopt($curl_handle, CURLOPT_URL, &#039;http://www.plurk.com/TimeLine/addPlurk&#039;);
	curl_setopt($curl_handle, CURLOPT_POSTFIELDS, &#039;qualifier=%3A&amp;content=&#039; . urlencode($msg) . &#039;&amp;lang=en&amp;no_comments=0&amp;uid=&#039;.$uid);
	curl_exec($curl_handle);
	curl_close($curl_handle);
	return;
}</pre>
<p>認證失敗的回傳字串：login:/Users/showLogin?nick_name=ooxx&#038;error=incorrect_login<br />
認證成功的回傳字串：login:/user/ooxx<br />
重覆PO文的回傳字串：anti-flood-same-content</p>
<p>2008/07/07 補充：因修改Permalinks造成<a href="http://funp.com/t253291" target="_blank">FunP</a>的推數消失。<br />
2008/07/08 補充：如果你是使用<a href="http://www.apachefriends.org/zh_tw/xampp.html" target="_blank">XAMPP</a>要開啟 curl 模組，只要修改xampp目錄（預設是c:\xampp）下的 /apache/bin/php.ini , /php/php.ini 將「extension=php_curl.dll」取消註解並重新啟動apache即可。<a href="http://www.xt-commerce.cn/docu/index.php/%E5%AE%89%E8%A3%9D%E5%95%8F%E9%A1%8C%E6%8E%92%E9%99%A4" target="_blank">參考資料</a><br />
2008/12/05 補充：由於Plurk系統更新，原來的功能無法使用，現改用 <a href="http://code.google.com/p/rlplurkapi/" target="_blank">RLPlurkAPI-0.5.0-0</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://klcin.tw/net/po3/feed</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>

