<?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/"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
>

<channel>
	<title>森の夢 &#187; twitter</title>
	<atom:link href="http://morinoyume.com/category/techs/twitter/feed/" rel="self" type="application/rss+xml" />
	<link>http://morinoyume.com</link>
	<description>渋谷で働く若手ＳＥの日々の日記。</description>
	<lastBuildDate>Thu, 11 Feb 2010 05:10:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://morinoyume.com/category/techs/twitter/feed/" />
		<item>
		<title>phpでtwitterにつぶやく。(&#8221;Services/Twitter.php&#8221;)</title>
		<link>http://morinoyume.com/techs/php%e3%81%a7twitter%e3%81%ab%e3%81%a4%e3%81%b6%e3%82%84%e3%81%8f%e3%80%82servicestwitter-php/</link>
		<comments>http://morinoyume.com/techs/php%e3%81%a7twitter%e3%81%ab%e3%81%a4%e3%81%b6%e3%82%84%e3%81%8f%e3%80%82servicestwitter-php/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 01:37:01 +0000</pubDate>
		<dc:creator>YSU</dc:creator>
				<category><![CDATA[twitter]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[pear]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://morinoyume.com/?p=408</guid>
		<description><![CDATA[今日はphpでtwitterに呟く方法を書く。
twitterはapiで呟けるが、phpにはpearに（Services/Twitter.php）という便利なモジュールがあるので、
今回はそれを使う。細かい使い方はココが [...]]]></description>
			<content:encoded><![CDATA[<p>今日はphpでtwitterに呟く方法を書く。<br />
twitterはapiで呟けるが、phpにはpearに（Services/Twitter.php）という便利なモジュールがあるので、<br />
今回はそれを使う。細かい使い方は<a href="http://labs.transrain.net/products/services_twitter/">ココ</a>が詳しい。<br />
まずは.pearの"Services/Twitter.php"が無いと話にならない。インストール。</p>
<pre class="brush: plain;">
  pear install --alldeps -f http://labs.transrain.net/files/Services_Twitter-0.4.0.tgz
</pre>
<p>以下は呟くときのサンプルソース。ID,Password,呟きたい内容を引数に渡せば勝手に呟いてくれる関数だ。<br />
140文字を超えている場合は135文字に切って「...」をつけてくれる。<br />
*phpインストール時に"--enable-mbstring"オプションがないと、140文字の部分が動かないかも。</p>
<pre class="brush: plain;">
  public static function tweet($id = null , $pass = null ,  $tweet )
  {
    //ServicesTwitterの読み込み。
    require_once &quot;Services/Twitter.php&quot;;

    //140文字を超えていたら、135文字で切って...をつける。
    if(mb_strlen($tweet)&gt; 140 )
    {
      $tweet = mb_substr( $tweet , 0 , 135 );
      $tweet .= &quot;... &quot;;
    }

    $st =&amp; new Services_Twitter( $id , $pass );
    $st-&gt;setUpdate($tweet);
  }
</pre>
<p>あとは、呼び出し側で、</p>
<pre class="brush: plain;">
self::tweet(&quot;morinoyume&quot; , &quot;morinoyume&quot; , &quot;森の夢だよーん&quot;)
</pre>
<p>とでもやれば、morinoyumeアカウントに呟かれるだろう。<br />
twitterのＡＰＩ簡単だね。もっと勉強していきます！</p>
<h3  class="related_post_title">関連の記事</h3><ul class="related_post"><li>2010 年 2 月 7 日 -- <a href="http://morinoyume.com/techs/symfony1-4%e3%81%a7zend%e3%81%ae%e3%83%a9%e3%82%a4%e3%83%96%e3%83%a9%e3%83%aa%e3%82%92%e4%bd%bf%e3%81%86%e3%80%82/" title="Symfony(1.4)でZendのライブラリを使う。">Symfony(1.4)でZendのライブラリを使う。</a></li><li>2010 年 1 月 26 日 -- <a href="http://morinoyume.com/techs/symfony1-4symfony1-3%e3%81%a7%e3%83%90%e3%83%83%e3%83%81%e5%87%a6%e7%90%86/" title="Symfony1.4(Symfony1.3)でバッチ処理">Symfony1.4(Symfony1.3)でバッチ処理</a></li><li>2010 年 1 月 20 日 -- <a href="http://morinoyume.com/techs/php%e3%81%ae%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89%e3%83%a9%e3%82%a4%e3%83%b3%e3%81%a7argv%e3%81%8cnull%e3%81%ae%e3%81%be%e3%81%be%ef%bc%88php-notice-undefined-variable-argv%ef%bc%89/" title="PHPのコマンドラインで$argvがNULLのまま（PHP Notice: Undefined variable: argv）">PHPのコマンドラインで$argvがNULLのまま（PHP Notice: Undefined variable: argv）</a></li><li>2010 年 1 月 18 日 -- <a href="http://morinoyume.com/techs/ethna%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f%e3%80%82/" title="Ethnaをインストールしてみた。">Ethnaをインストールしてみた。</a></li><li>2009 年 11 月 29 日 -- <a href="http://morinoyume.com/techs/phpmyadmin%e3%81%a7%e3%82%a8%e3%83%a9%e3%83%bc%e3%81%af%e3%81%aa%e3%81%84%e3%81%8c%e3%83%ad%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%a7%e3%81%8d%e3%81%aa%e3%81%84%e7%8f%be%e8%b1%a1%e3%81%ab%e3%81%a4%e3%81%84/" title="phpMyAdminでエラーはないがログインできない現象について">phpMyAdminでエラーはないがログインできない現象について</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://morinoyume.com/techs/php%e3%81%a7twitter%e3%81%ab%e3%81%a4%e3%81%b6%e3%82%84%e3%81%8f%e3%80%82servicestwitter-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://morinoyume.com/techs/php%e3%81%a7twitter%e3%81%ab%e3%81%a4%e3%81%b6%e3%82%84%e3%81%8f%e3%80%82servicestwitter-php/" />
	</item>
	</channel>
</rss>
