<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8406651269900027144</id><updated>2014-06-22T08:48:31.860+09:00</updated><category term="PHP"/><category term="Twitter"/><category term="Mail"/><category term="ZendFramework"/><category term="iOS"/><category term="Apple"/><category term="Objective-C"/><category term="SMTP"/><category term="Smarty"/><category term="Xcode"/><category term="iPad"/><category term="iPhone"/><title type='text'>仕事を早く片付けて遊ぶための技術ノート</title><subtitle type='html'>ITエンジニアの開発ネタ話</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://yanagawadon.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://yanagawadon.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>史上最強のニュース速報</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8406651269900027144.post-3403607884785004129</id><published>2011-11-30T00:07:00.004+09:00</published><updated>2011-11-30T00:24:24.392+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Twitter"/><title type='text'>Twitterのつぶやき制限</title><content type='html'>TwitterでBotなんか作ってたりすると、頻繁につぶやいていたらいつの間にかエラーが発生してつぶやけなくなってたりする事があります。&lt;br /&gt;&lt;br /&gt;例えば、APIで下記のような感じで一定時間の間つぶやいていたりするとします&lt;br /&gt;&lt;br /&gt;&lt;pre class=&#39;brush:php&#39;&gt;&lt;br /&gt;try {&lt;br /&gt;   $twitter = new Services_Twitter();&lt;br /&gt;     $oauth = new HTTP_OAuth_Consumer(consumer_key, consumer_secret, auth_token, token_secret);&lt;br /&gt;     $twitter-&gt;setOAuth($oauth);&lt;br /&gt; $statuses =  sprintf(&quot;鈴木の借金は今現在¥%s&quot;, number_format(10000000); );&lt;br /&gt; $twitter-&gt;statuses-&gt;update($statuses);&lt;br /&gt;} catch (Exception $e) {&lt;br /&gt;  printf(&quot;%s(%d): %s\n&quot;, __FILE__, __LINE__, $e-&gt;getMessage());&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;このとき、一定時間のつぶやき回数上限エラーでException(User is over daily status update limit.)が発生します。これが発生する条件ですが、今一つはっきりしないものの、実際検証したところ50回/時間で2-3時間実行すると発生する事が確認できました。&lt;br /&gt;&lt;br /&gt;スクリプトの実行方法があまりに悪質な場合(殆どサーバーアタックに近いくらいの度を超したアクセス回数)を除き、上記のエラーは約２時間前後スクリプトの実行停止後復旧します。「度を超した場合」はおそらくアカウント自体が凍結されてしまい、Twitterさん宛に面倒くさい謝罪文を英文で送らないと復旧できないと思います。その他、同一アカウント宛の短時間でのmention連投も悪質行為と見なされ、アカウントがフリーズする可能性が高いです。&lt;br /&gt;&lt;br /&gt;みなさん、くれぐれもTwitterは健全な使い方をするよう心がけましょう♪</content><link rel='replies' type='application/atom+xml' href='http://yanagawadon.blogspot.com/feeds/3403607884785004129/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/twitter_30.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/3403607884785004129'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/3403607884785004129'/><link rel='alternate' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/twitter_30.html' title='Twitterのつぶやき制限'/><author><name>柳川丼</name><uri>http://www.blogger.com/profile/02045178650595422120</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8406651269900027144.post-5249231472739420986</id><published>2011-11-25T20:02:00.004+09:00</published><updated>2011-11-25T20:17:22.564+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Mail"/><title type='text'>sendmail: savemail: cannot save rejected email anywhere</title><content type='html'>CentOSをはじめ最近のlinuxディストリビューションのSMTPサーバーはPostfixがスタンダード化しつつありますが、単にメール送信するだけだったらsendmailで済ませたいと思うところです。そこで、sendmailを使うための必要最低限の設定ですが&lt;br /&gt;&lt;br /&gt;shell&gt; yum install -y sendmail&lt;br /&gt;shell&gt; vi /etc/mail/sendmail.mc&lt;br /&gt;※以下を追記/編集&lt;br /&gt;-Dw{ホスト名}&lt;br /&gt;-Dm{ドメイン名}&lt;br /&gt;-define(`confDOMAIN_NAME&#39;,`$w.$m&#39;)dnl&lt;br /&gt; -dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA&#39;)dnl  ←コメントで無効にする&lt;br /&gt;&lt;br /&gt;shell&gt; /etc/init.d/sendmail start&lt;br /&gt;&lt;br /&gt;とりあえずこれだけでローカルマシン内でもメールが使えるような気もしますが、試しにroot@localhost宛にメールを&lt;br /&gt;送ったところ/varlog/maillogに「savemail: cannot save rejected email anywhere」のようなエラーが出力されます。&lt;br /&gt;&lt;br /&gt;これは、/etc/host.allowに以下の設定を追記することで解決します。&lt;br /&gt;&lt;br /&gt;sendmail: ALL (or LOCAL)&lt;br /&gt;&lt;br /&gt;※sendmailを再起動する&lt;br /&gt;&lt;br /&gt;RELAY設定はデフォルトでローカルマシンからのメールのみ受け付けるようになっていますが、必ず確認して不正利用されることがないようにしてください。</content><link rel='replies' type='application/atom+xml' href='http://yanagawadon.blogspot.com/feeds/5249231472739420986/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/sendmail-savemail-cannot-save-rejected.html#comment-form' title='1 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/5249231472739420986'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/5249231472739420986'/><link rel='alternate' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/sendmail-savemail-cannot-save-rejected.html' title='sendmail: savemail: cannot save rejected email anywhere'/><author><name>柳川丼</name><uri>http://www.blogger.com/profile/02045178650595422120</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8406651269900027144.post-5984123541188417440</id><published>2011-11-23T18:09:00.003+09:00</published><updated>2011-11-23T18:14:06.012+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>PHPでMeCabを使う</title><content type='html'>※MeCabはインストール済み&lt;br /&gt;&lt;br /&gt;PECLライブラリをインストールする&lt;br /&gt;&lt;br /&gt;&lt;pre class=&#39;brush: bash;&#39;&gt;&lt;br /&gt;wget http://www.opendogs.org/pub/php_mecab-0.4.0.tgz&lt;br /&gt;tar xvzf php_mecab-0.4.0.tgz &lt;br /&gt;cd php_mecab-0.4.0&lt;br /&gt;phpize&lt;br /&gt;./configure&lt;br /&gt;make&lt;br /&gt;make install&lt;br /&gt;vi /usr/local/php/lib/php.ini # extension=mecab.so を追記&lt;br /&gt;/etc/init.d/httpd restart &lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://yanagawadon.blogspot.com/feeds/5984123541188417440/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/phpmecab.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/5984123541188417440'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/5984123541188417440'/><link rel='alternate' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/phpmecab.html' title='PHPでMeCabを使う'/><author><name>柳川丼</name><uri>http://www.blogger.com/profile/02045178650595422120</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8406651269900027144.post-8166202550687251090</id><published>2011-11-23T00:48:00.016+09:00</published><updated>2011-11-23T12:48:58.432+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>Fileinfoでエラーが発生する（Failed to load magic database at &#39;/usr/share/misc/magic&#39;）</title><content type='html'>&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;PHPの組み込みライブラリであるFileinfoですが(5.2.x以前は拡張ライブラリ)、ファイルのMimeType判定時に利用する事が多いかと思いますが、&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;例えば以下のようなコードを実行したとします。&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;brush: php;&quot;&gt;$fileinfo = finfo_open(FILEINFO_MIME);&lt;br /&gt;$mimetype = finfo_file($finfo, $filename);&lt;br /&gt;finfo_close($finfo);&lt;/pre&gt;&lt;br /&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;この際に「Failed to load magic database at &#39;/usr/share/misc/magic&#39;」というエラーが発生する場合があります。finfo_open関数は本来&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;finfo_open(Fileinfo定数, magicデータベースファイル);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;という二つの引数を指定します。「&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;magicデータベースファイル&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;」は省略可能ですが、その場合”&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;/usr/share/misc/magic&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;”というファイルを参照します。エラーが発生する原因としては、&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;・参照している&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;「&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;magicデータベースファイル&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;」が存在しない&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;font-family: Georgia, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;・参照している&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;「&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;magicデータベースファイル&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;」は存在するが、ファイルの内容が正しいものではない&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Georgia, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Georgia, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;のいずれかが考えられます。前者の場合はlsコマンドで容易に確認できますが、後者の場合に関しての確認方法は以下のように行います。&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Georgia, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Georgia, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;(1) fileコマンドが正しくインストールされているのであれば、システムに存在するmagicデータベースファイルと思われるものを探す。&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Georgia, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Georgia, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;find /usr -name magic&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Georgia, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;(2) &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt; &#39;/usr/share/misc/magic&#39;以外に存在する&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;magicデータベースファイルが見つかったら、fileコマンドで正しい内容のファイルかどうか確認する。&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;file -i -b -m &#39;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;magicデータベースファイル&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;&#39; ファイル名(確認用なので何でも良い)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;ここで、コマンド実行結果として期待した&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;MimeType&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;;&quot;&gt;が表示されれば正しい内容のファイルといえます。自分の環境では、&#39;/usr/share/magic&#39;というファイルがこれに該当しました。よって、先ほどエラーが発生したコードに対して以下のような修正を行う事で、エラー対処が行えます。&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;pre class=&quot;brush: php;&quot;&gt;$fileinfo = finfo_open(FILEINFO_MIME, &#39;/usr/share/magic&#39;); // magicデータベースファイルを明示的に指定する。&lt;br /&gt;$mimetype = finfo_file($finfo, $filename);&lt;br /&gt;finfo_close($finfo);&amp;nbsp;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://yanagawadon.blogspot.com/feeds/8166202550687251090/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/fileinfofailed-to-load-magic-database.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/8166202550687251090'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/8166202550687251090'/><link rel='alternate' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/fileinfofailed-to-load-magic-database.html' title='Fileinfoでエラーが発生する（Failed to load magic database at &#39;/usr/share/misc/magic&#39;）'/><author><name>柳川丼</name><uri>http://www.blogger.com/profile/02045178650595422120</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8406651269900027144.post-968288185063356095</id><published>2011-11-21T23:56:00.014+09:00</published><updated>2011-11-23T13:37:38.525+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>FC2ブログに自動投稿する</title><content type='html'>&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;; font-size: 85%;&quot;&gt;最近2chまとめサイト系のブログページが流行ってるけど、中でもFC2ブログへ自動投稿するニーズが多いようなので、巷に出回ってるアップローダーを若干シンプルにしたものを書いてみた。&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;pre class=&quot;brush: php;&quot;&gt;require_once(&quot;XML/RPC.php&quot;);&lt;br /&gt; &lt;br /&gt;//XML-RPCインタフェース、ユーザ定義&lt;br /&gt; &lt;br /&gt;$host = &quot;blog.fc2.com&quot;;&lt;br /&gt;$xmlrpc = &quot;/xmlrpc.php&quot;;&lt;br /&gt; &lt;br /&gt;define(&#39;USERNAME&#39;, &#39;FC2のユーザー名&#39;);&lt;br /&gt;define(&#39;PASSWORD&#39;, &#39;FC2のパスワード&#39;);&lt;br /&gt;define(&#39;CATEGORY&#39;, &#39;FC2ブログのカテゴリ名&#39;);&lt;br /&gt; &lt;br /&gt;//投稿内容&lt;br /&gt;$title = &quot;自動投稿のテスト&quot;; // ブログ記事のタイトル&lt;br /&gt;$content = &quot;自動投稿のテスト。&lt;br&gt;とりあえずこんな事書いてみる。&quot;; // ブログ記事の本文&lt;br /&gt;$GLOBALS[&#39;XML_RPC_defencoding&#39;] = &quot;UTF-8&quot;;&lt;br /&gt; &lt;br /&gt;//クライアントの作成&lt;br /&gt;$c = new XML_RPC_client($xmlrpc, $host, 80);&lt;br /&gt; &lt;br /&gt;//メッセージ作成&lt;br /&gt;$blogid = new XML_RPC_Value(0, &#39;string&#39;);&lt;br /&gt;$username = new XML_RPC_Value(USERNAME, &#39;string&#39;);&lt;br /&gt;$password = new XML_RPC_Value(PASSWORD, &#39;string&#39;);&lt;br /&gt;$content = new XML_RPC_Value(&lt;br /&gt;　array(&lt;br /&gt;　　&#39;title&#39;=&gt; new XML_RPC_Value($title, &#39;string&#39;),&lt;br /&gt;　　&#39;description&#39;=&gt; new XML_RPC_Value($content, &#39;string&#39;),&lt;br /&gt;　　&#39;dateCreated&#39;=&gt; new XML_RPC_Value(date(&quot;Ymd\TH:i:s&quot;,time()), &#39;dateTime.iso8601&#39;)&lt;br /&gt;　)&lt;br /&gt;, &#39;struct&#39;);&lt;br /&gt; &lt;br /&gt;$publish = new XML_RPC_Value(1, &#39;boolean&#39;);&lt;br /&gt;$message = new XML_RPC_Message(&#39;metaWeblog.newPost&#39;, array($blogid, $username, $password, $content, $publish));&lt;br /&gt; &lt;br /&gt;// ブログの投稿&lt;br /&gt;$postid = $c-&gt;send($message);&lt;br /&gt;// ブログのカテゴリを設定&lt;br /&gt;$message = new XML_RPC_Message(&#39;mt.getCategoryList&#39;, array($blogid, $username, $password));&lt;br /&gt;$category_list = $c-&gt;send($message);&lt;br /&gt;$categories = $category_list-&gt;value();&lt;br /&gt; &lt;br /&gt;for ($i = 0; $i &lt; $categories-&gt;arraysize(); $i++) {&lt;br /&gt;　$category_pair = $categories-&gt;arraymem($i);&lt;br /&gt;　$category_id = $category_pair-&gt;structmem(&quot;categoryId&quot;);&lt;br /&gt;　$category_name = $category_pair-&gt;structmem(&quot;categoryName&quot;);&lt;br /&gt;　if (strcmp($category_name-&gt;scalarval(), CATEGORY) == 0) {&lt;br /&gt;　　$category_set = array(&#39;categoryId&#39;=&gt; $category_id, &#39;isPrimary&#39;=&gt; new XML_RPC_Value(1, &#39;boolean&#39;));&lt;br /&gt;　　$category = new XML_RPC_Value(array(new XML_RPC_Value($category_set, &#39;struct&#39;)), &#39;array&#39;);&lt;br /&gt;　　$message = new XML_RPC_Message(&#39;mt.setPostCategories&#39;, array($postid-&gt;value(), $username, $password, $category));&lt;br /&gt;　　$retval = $c-&gt;send($message);&lt;br /&gt; &lt;br /&gt;　　if (!$retval || $retval-&gt;faultCode() != 0) {&lt;br /&gt;　　　return false;&lt;br /&gt;　　}&lt;br /&gt;　　break;&lt;br /&gt;　}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://yanagawadon.blogspot.com/feeds/968288185063356095/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/fc2.html#comment-form' title='1 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/968288185063356095'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/968288185063356095'/><link rel='alternate' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/fc2.html' title='FC2ブログに自動投稿する'/><author><name>柳川丼</name><uri>http://www.blogger.com/profile/02045178650595422120</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8406651269900027144.post-4552259999271592608</id><published>2011-11-19T19:59:00.003+09:00</published><updated>2011-11-19T20:06:24.308+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="Objective-C"/><title type='text'>iOSアプリのテキスト表示にグロー（発光）効果を適用する</title><content type='html'>&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;lucida grande&#39;;&quot;&gt;サンプルコード&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;- (&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#AA0D91;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;)drawRect:(&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#5C2699;&quot;&gt;CGRect&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;)rect&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font: normal normal normal 11px/normal Menlo-Regular; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:Monaco;font-size:78%;&quot;&gt;　&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#5C2699;&quot;&gt;CGContextRef&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt; context = &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;UIGraphicsGetCurrentContext&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;();&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font: normal normal normal 11px/normal Menlo-Regular; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:Monaco;font-size:78%;&quot;&gt;　&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#5C2699;&quot;&gt;CGColorRef&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt; glowColor = &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;CGColorCreateCopyWithAlpha&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;([[&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#5C2699;&quot;&gt;UIColor&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;blueColor&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;] &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;CGColor&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;], &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#1C00CF;&quot;&gt;0.85f&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:Monaco;font-size:78%;&quot;&gt;　&lt;/span&gt;[[&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#5C2699;&quot;&gt;UIColor&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;whiteColor&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;] &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;];&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;CGContextSetShadowWithColor&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;( context, &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;CGSizeMake&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;( &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#1C00CF;&quot;&gt;0.0&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;, -&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#1C00CF;&quot;&gt;1.0&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt; ), &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#1C00CF;&quot;&gt;3.0f&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;, glowColor ); &lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font: normal normal normal 11px/normal Menlo-Regular; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:Monaco;font-size:78%;&quot;&gt;　&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;CGColorRelease&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;(glowColor);&lt;br /&gt; &lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font: normal normal normal 11px/normal Menlo-Regular; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:Monaco;font-size:78%;&quot;&gt;　&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#5C2699;&quot;&gt;NSString&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt; *text = [&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#5C2699;&quot;&gt;NSString&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;stringWithString&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;:&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#C41A16;&quot;&gt;@&quot;Cool glowing text..1234 5678&quot;&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;];&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:Monaco;font-size:78%;&quot;&gt;　&lt;/span&gt;[text &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;drawAtPoint&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;:&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;CGPointMake&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#1C00CF;&quot;&gt;25.0f&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#1C00CF;&quot;&gt;0.5f&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;) &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;withFont&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;:[&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#5C2699;&quot;&gt;UIFont&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;fontWithName&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;:&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#C41A16;&quot;&gt;@&quot;Thonburi-Bold&quot;&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;:&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#1C00CF;&quot;&gt;22.0f&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;]];&lt;br /&gt; &lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font: normal normal normal 11px/normal Menlo-Regular; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:Monaco;font-size:78%;&quot;&gt;　&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#5C2699;&quot;&gt;CGColorRef&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt; shadowColor = &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;CGColorCreateCopyWithAlpha&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;([[&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#5C2699;&quot;&gt;UIColor&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;blackColor&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;] &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;CGColor&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;], &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#1C00CF;&quot;&gt;0.70f&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font: normal normal normal 11px/normal Menlo-Regular; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:Monaco;font-size:78%;&quot;&gt;　&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;CGContextSetShadowWithColor&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;(context, &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;CGSizeMake&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#1C00CF;&quot;&gt;0.0f&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#1C00CF;&quot;&gt;1.0f&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;), &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#1C00CF;&quot;&gt;0.0f&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;, shadowColor);&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font: normal normal normal 11px/normal Menlo-Regular; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:Monaco;font-size:78%;&quot;&gt;　&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;CGColorRelease&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;(shadowColor);&lt;br /&gt;　[&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;text &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;drawAtPoint&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;:&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;CGPointMake&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#1C00CF;&quot;&gt;25.0f&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#1C00CF;&quot;&gt;0.5f&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;) &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;withFont&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;:[&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#5C2699;&quot;&gt;UIFont&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;fontWithName&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;:&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#C41A16;&quot;&gt;@&quot;Thonburi-Bold&quot;&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#2E0D6E;&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;:&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; color:#1C00CF;&quot;&gt;22.0f&lt;/span&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;]];&lt;br /&gt; &lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:100%;&quot;&gt;実行例&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;img style=&quot;float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 308px; height: 64px;&quot; src=&quot;http://www.softwareops.com/blogs/iPhone/iPhoneDevBlog_files/pasted-graphic.jpg&quot; border=&quot;0&quot; alt=&quot;&quot; /&gt;&lt;div&gt;&lt;span style=&quot;font:11px Menlo-Regular; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:100%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yanagawadon.blogspot.com/feeds/4552259999271592608/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/ios_19.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/4552259999271592608'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/4552259999271592608'/><link rel='alternate' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/ios_19.html' title='iOSアプリのテキスト表示にグロー（発光）効果を適用する'/><author><name>柳川丼</name><uri>http://www.blogger.com/profile/02045178650595422120</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8406651269900027144.post-391797895834576109</id><published>2011-11-19T19:20:00.004+09:00</published><updated>2011-11-23T13:11:38.002+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Mail"/><category scheme="http://www.blogger.com/atom/ns#" term="SMTP"/><category scheme="http://www.blogger.com/atom/ns#" term="ZendFramework"/><title type='text'>Zend_Mailによるメール送信</title><content type='html'>&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;lucida grande&#39;; font-size: 85%;&quot;&gt;Zend_Mailによるメール送信を行う場合の実装例です。単純に送信するだけであればそれほど難しくはありませんが、メールサーバーによって文字エンコーディングの処理に若干の違いがあり、実装が不十分だと文字化けが発生しやすいため要注意です。&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;brush: php;&quot;&gt;class SendMail {&lt;br /&gt;　private static function convertEncodeing($text) {&lt;br /&gt;　　return mb_convert_encoding($text, &#39;ISO-2022-JP&#39;, &#39;UTF-8&#39;);&lt;br /&gt;　}&lt;br /&gt;&lt;br /&gt;　// メール送信(宛先 題名 本文を指定する。送信元は固定)&lt;br /&gt;　public static function sendMail($to, $subject, $content) {&lt;br /&gt;　　$options = new Zend_Config_Ini(APPLICATION_PATH . &#39;/configs/application.ini&#39;, APPLICATION_ENV);&lt;br /&gt;&lt;br /&gt;　　$errorMessage = &quot;&quot;;&lt;br /&gt;　　$config = array();&lt;br /&gt;&lt;br /&gt;　　try {&lt;br /&gt;　　　// SMTP認証を行う場合&lt;br /&gt;　　　if (strlen($options-&gt;mail-&gt;smtp-&gt;auth) &gt; 0) {&lt;br /&gt;　　　　$config[&#39;auth&#39;] = $options-&gt;mail-&gt;smtp-&gt;auth;&lt;br /&gt;　　　　$config[&#39;username&#39;] = $options-&gt;mail-&gt;smtp-&gt;username;&lt;br /&gt;　　　　$config[&#39;password&#39;] = $options-&gt;mail-&gt;smtp-&gt;password;&lt;br /&gt;　　　}&lt;br /&gt;&lt;br /&gt;　　　// 暗号化を行う場合&lt;br /&gt;　　　if (strlen($options-&gt;mail-&gt;smtp-&gt;ssl) &gt; 0) {&lt;br /&gt;　　　　$config[&#39;ssl&#39;] = $options-&gt;mail-&gt;smtp-&gt;ssl;&lt;br /&gt;　　　}&lt;br /&gt;&lt;br /&gt;　　　$transport = new Zend_Mail_Transport_Smtp($options-&gt;mail-&gt;smtp-&gt;host, $config);&lt;br /&gt;&lt;br /&gt;　　　$mail = new Zend_Mail(&#39;ISO-2022-JP&#39;);&lt;br /&gt;　　　$mail-&gt;setBodyText(MailManager::convertEncodeing($content), null, Zend_Mime::ENCODING_7BIT);&lt;br /&gt;&lt;br /&gt;　　　// Fromに表示されるメールアドレスと名称&lt;br /&gt;　　　$from = mb_encode_mimeheader(mb_convert_encoding($options-&gt;mail-&gt;address-&gt;from, &#39;JIS&#39;, &#39;auto&#39;), &#39;iso-2022-jp&#39;);&lt;br /&gt;　　　$mail-&gt;setFrom($options-&gt;mail-&gt;address-&gt;sender, $from);&lt;br /&gt;&lt;br /&gt;　　　// メールの返信先(デフォルトはFrom)&lt;br /&gt;　　　$mail-&gt;setReplyTo(strlen($options-&gt;mail-&gt;address-&gt;replyto) &gt; 0 ? $options-&gt;mail-&gt;address-&gt;replyto : $options-&gt;mail-&gt;address-&gt;sender);&lt;br /&gt;&lt;br /&gt;　　　// エラーメールの返信先(デフォルトはFrom)&lt;br /&gt;　　　$mail-&gt;setReturnPath(strlen($options-&gt;mail-&gt;returnpath) &gt; 0 ? $options-&gt;mail-&gt;returnpath : $options-&gt;mail-&gt;sender);&lt;br /&gt;　　　$mail-&gt;addTo($to);&lt;br /&gt;&lt;br /&gt;　　　// Gmail対策(Postfix等では問題ないが、Gmailではこのエンコーディングが無いと文字化けが発生する)&lt;br /&gt;&lt;br /&gt;　　　$subject = mb_encode_mimeheader(mb_convert_encoding($subject, &#39;JIS&#39;, &#39;auto&#39;), &#39;iso-2022-jp&#39;);&lt;br /&gt;　　　$mail-&gt;setSubject($subject);&lt;br /&gt;&lt;br /&gt;　　　if ($transport-&gt;getConnection() != NULL) {&lt;br /&gt;　　　　$mail-&gt;send($transport);&lt;br /&gt;　　　} else {&lt;br /&gt;　　　　// SMTPサーバーが使用できない場合&lt;br /&gt;　　　　$mail-&gt;send();&lt;br /&gt;　　　}&lt;br /&gt;　　} catch (Exception $e) {&lt;br /&gt;　　　// エラー発生時にログを出力する&lt;br /&gt;　　　global $logger;&lt;br /&gt;　　　$errorMessage = $e-&gt;getMessage();&lt;br /&gt;　　　$logger-&gt;log(sprintf(&quot;%s(%d): %s&quot;, __FILE__, __LINE__, $errorMessage), Zend_Log::ERR);&lt;br /&gt;　　}&lt;br /&gt;　　return $errorMessage;&lt;br /&gt;　}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://yanagawadon.blogspot.com/feeds/391797895834576109/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/zendmail.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/391797895834576109'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/391797895834576109'/><link rel='alternate' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/zendmail.html' title='Zend_Mailによるメール送信'/><author><name>柳川丼</name><uri>http://www.blogger.com/profile/02045178650595422120</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8406651269900027144.post-8304318995176493571</id><published>2011-11-19T18:55:00.003+09:00</published><updated>2011-11-19T19:13:16.984+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Apple"/><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="iPad"/><category scheme="http://www.blogger.com/atom/ns#" term="iPhone"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode"/><title type='text'>iOSアプリの公開手順</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;開発が完了しアプリパッケージが用意できたiOS(iPhone/iPad/iPod Touch)アプリの公開手順&lt;/span&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;※既にiTunes Connectには公開対象のアプリに関するメタ情報（アプリ名称/アプリ説明/公開対象国/スナップショット/アイコン等）は登録済みという前提。以下の説明は、公開用アプリのバイナリパッケージの作成→アップロードまでの手順となります。&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;(1) 公開証明書の作成&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・MacOS でApplication→Utilities→キーチェーンアクセスを起動する。&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・メニューから「証明書アシスタント」→「認証局に証明書を要求」をクリック。メアドとかを適当に入力し、「要求の処理」を「ディスクに保存」にして「続ける」をクリック。「CertificateSigningRequest.certSigningRequest」というファイルができるので保存しておく。&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;(2) 公開証明書の登録&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・iOS Dev Centerにアクセス。ログインして、右側の「iOS Provisioning Portal」、左側の「Certificates」へ移動。&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・「Distribution」タブで「Request Certificate」ボタンをクリック、&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・「ファイルを選択」を押して、先ほど作った「CertificateSigningRequest.certSigningRequest」というファイルを選択してSubmitする&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・しばらくすると「Status」が「Pending Issuance」から「Issued」になる&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・「Issued」になったらDownloadボタンから「distribution_identity.cer」をダウンロードして実行。&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・同じページにある「AppleWWDRCA.cer」もダウンロードして実行する。&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・キーチェーンアクセスに２つ証明書が追加されたのを確認する。&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;(3) App IDの作成&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・「Provisioning Portal」→「App IDs」→「New App ID」→「Create App ID」&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・「Description」に通称または説明を入力&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・「Bundle Seed ID (App ID Prefix)」は「Generate New」&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・「Bundle Identifier (App ID Suffix)」には他とかぶらないように入れる。自分のドメインを逆から書いたものが推奨されている。入れたらSubmit。&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;(4) Provisioningファイルの作成と登録&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・左のメニューから「Provisioning」に移動して「Distribution」タブ&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・「New Profile」を押して「Create iPhone Distribution Provisioning Profile」へ&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・「Distribution Method」→「App Store」&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・「Profile Name」→アプリ名&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・「Distribution Certificate」→公開用証明書作ったときの名前が表示されている&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・「App ID」→さっきのAppID&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・「Devices (optional)」→そのまま（AdHoc用）で「Submit」&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・しばらくするとStatusが「Pending」から「Active」になる&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・Downloadを押してProvisioning Profilesをダウンロード&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・「[さっき入れた名前].mobileprovision」を適当な場所に保存&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・ダブルクリックしてオーガナイザに登録（「IPHONE DEVELOPMENT」→「Provisioning Profiles」に登録される）&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;(5) Distributionビルドを作る&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・Xcodeでプロジェクトを開く&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・「Info.plist」ファイルの「Bundle identifier」を先ほど登録したAppIDにする&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・メニューの「プロジェクト」→「プロジェクト設定を変更」を選択、&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・「ビルド」タブの「コード署名ID」の「Any iPhone OS Device」で、設定したProvisioning Profilesを選択&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・「構成」タブで「Release」を選択し左下の「複製」をクリック、「Releaseのコピー」がができるので名前を「Distribution」に変更&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・概要でアクティブなSDKに「Device」を，アクティブな構成に「Distribution」&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・iOS3.xと4.0の両方で動作するようにビルドする場合はこちらを参照。「ベースSDK」を「iPhoneデバイス4.0」にして、「iPhone OS Deployment Target」 を低いバージョンにし、新しいOSじゃないと使えないFrameworkをWeak Linkにする。&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;iOS 4.0 と iPhone OS 3.x の両方で動作するアプリケーションをビルドする設定&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・Xcodeのメインウィンドウの画面の左上のボタンで、「Device」を選び、「アクティブな構成」を「Distribution」にする。&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・Distribution用のビルドをするために、メニューから「ビルド」の「ビルド」をクリックしてビルド。（キーチェーンがどうとか聞かれたら「常に許可」を選択）&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・ビルドが通ったら、プロジェクトが保存されているフォルダに行き、「build」の「Distribution-iphones」へ移動&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;・そこにある拡張子.appのファイルを右クリックし、zip圧縮する。&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;※Ad-Hoc配布時に入れる「Entitlement.plist」はアップロード時に署名エラーが発生するためZipに混在させないこと。&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;(6) アプリアップロード&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;Application Loader(Xcode付属、もしくはiTunes Connectの「Application Loader Instructional」からダウンロード)をインストールし、zip圧縮したアプリをアップロードする。&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;間もなくステータスが&quot;In Review&quot;となるので、アプリ審査が完了するのを待つ事となります。（通常５日前後）&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yanagawadon.blogspot.com/feeds/8304318995176493571/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/ios.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/8304318995176493571'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/8304318995176493571'/><link rel='alternate' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/ios.html' title='iOSアプリの公開手順'/><author><name>柳川丼</name><uri>http://www.blogger.com/profile/02045178650595422120</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8406651269900027144.post-4787887705940482899</id><published>2011-11-19T18:29:00.006+09:00</published><updated>2011-11-19T18:55:26.856+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Twitter"/><title type='text'>Twitter: consumer_key, consumer_secret, auth_token, token_secret取得方法</title><content type='html'>&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;lucida grande&#39;;&quot;&gt;TwitterアプリでOauth認証を行う場合に必要となる各キーの取得方法は以下の通り&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;lucida grande&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;lucida grande&#39;;&quot;&gt;(1) Twitterアプリの開発用のアカウントで(&lt;a href=&quot;https://dev.twitter.com/&quot;&gt;https://dev.twitter.com/&lt;/a&gt;)にログイン(Sign In)する。&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;lucida grande&#39;;&quot;&gt;(2) My Applications(&lt;a href=&quot;https://dev.twitter.com/apps&quot;&gt;https://dev.twitter.com/apps&lt;/a&gt;)にアクセスする。既にアプリが登録済みであればアイコンとアプリ名称が表示されるが、未登録の場合は「Create a new application」を行う。&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;lucida grande&#39;;&quot;&gt;(3) My Applications →アプリ名称のリンクをクリックする。各種設定情報が表示されるが、「Detail」タブでは以下の情報が表示される。&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;lucida grande&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;color:#ff0000;&quot;&gt;・Consumer key&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;color:#ff0000;&quot;&gt;・Consumer secret&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;color:#ff0000;&quot;&gt;・Access token&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;color:#ff0000;&quot;&gt;・Access token secret&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;lucida grande&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;lucida grande&#39;;&quot;&gt;以上&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yanagawadon.blogspot.com/feeds/4787887705940482899/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/twitter-consumerkey-consumersecret.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/4787887705940482899'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/4787887705940482899'/><link rel='alternate' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/twitter-consumerkey-consumersecret.html' title='Twitter: consumer_key, consumer_secret, auth_token, token_secret取得方法'/><author><name>柳川丼</name><uri>http://www.blogger.com/profile/02045178650595422120</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8406651269900027144.post-1458485036650700079</id><published>2011-11-19T17:38:00.004+09:00</published><updated>2011-11-24T17:01:57.951+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><category scheme="http://www.blogger.com/atom/ns#" term="Smarty"/><category scheme="http://www.blogger.com/atom/ns#" term="ZendFramework"/><title type='text'>ZendFrameworkのテンプレートエンジンをSmartyに切替える</title><content type='html'>(1) Zend_View_Interfaceをインプリメントしたクラスを定義し、Smarty独自の実装を施す。作成したクラスはAPPLICATION_PATH/../library/Smarty.phpとして保存する。&lt;br /&gt;&lt;br /&gt;&lt;pre class=&#39;brush:php;&#39;&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;require_once(&#39;Smarty/Smarty.class.php&#39;);&lt;br /&gt;&lt;br /&gt;class Zend_View_Smarty implements Zend_View_Interface {&lt;br /&gt;　/**&lt;br /&gt;　* Smarty object&lt;br /&gt;　* @var Smarty&lt;br /&gt;　*/&lt;br /&gt;　protected $_smarty;&lt;br /&gt;&lt;br /&gt;　/**&lt;br /&gt;　* コンストラクタ&lt;br /&gt;　*&lt;br /&gt;　* @param string $tmplPath&lt;br /&gt;　* @param array $extraParams&lt;br /&gt;　* @return void&lt;br /&gt;　*/&lt;br /&gt;　public function __construct($tmplPath = null, $extraParams = array()) {&lt;br /&gt;　　$this-&gt;_smarty = new Smarty;&lt;br /&gt;&lt;br /&gt;　　if (null !== $tmplPath) {&lt;br /&gt;　　　$this-&gt;setScriptPath($tmplPath);&lt;br /&gt;　　}&lt;br /&gt;&lt;br /&gt;　　foreach ($extraParams as $key =&gt; $value) {&lt;br /&gt;　　　$this-&gt;_smarty-&gt;$key = $value;&lt;br /&gt;　　}&lt;br /&gt;　}&lt;br /&gt;&lt;br /&gt;　/**&lt;br /&gt;　* テンプレートエンジンオブジェクトを返します&lt;br /&gt;　*&lt;br /&gt;　* @return Smarty&lt;br /&gt;　*/&lt;br /&gt;　public function getEngine() {&lt;br /&gt;　　return $this-&gt;_smarty;&lt;br /&gt;　}&lt;br /&gt;&lt;br /&gt;　/**&lt;br /&gt;　* テンプレートへのパスを設定します&lt;br /&gt;　*&lt;br /&gt;　* @param string $path パスとして設定するディレクトリ&lt;br /&gt;　* @return void&lt;br /&gt;　*/&lt;br /&gt;　public function setScriptPath($path) {&lt;br /&gt;　　if (is_readable($path)) {&lt;br /&gt;　　　$this-&gt;_smarty-&gt;template_dir = $path;&lt;br /&gt;　　　return;&lt;br /&gt;　　}&lt;br /&gt;　　throw new Exception(&#39;無効なパスが指定されました&#39;);&lt;br /&gt;　}&lt;br /&gt;&lt;br /&gt;　/**&lt;br /&gt;　* 現在のテンプレートディレクトリを取得します&lt;br /&gt;　*&lt;br /&gt;　* @return string&lt;br /&gt;　*/&lt;br /&gt;　public function getScriptPaths() {&lt;br /&gt;　　return array($this-&gt;_smarty-&gt;template_dir);&lt;br /&gt;　}&lt;br /&gt;&lt;br /&gt;　/**&lt;br /&gt;　* setScriptPath へのエイリアス&lt;br /&gt;　*&lt;br /&gt;　* @param string $path&lt;br /&gt;　* @param string $prefix Unused&lt;br /&gt;　* @return void&lt;br /&gt;　*/&lt;br /&gt;　public function setBasePath($path, $prefix = &#39;Zend_View&#39;) {&lt;br /&gt;　　return $this-&gt;setScriptPath($path);&lt;br /&gt;　}&lt;br /&gt;&lt;br /&gt;　/**&lt;br /&gt;　* setScriptPath へのエイリアス&lt;br /&gt;　*&lt;br /&gt;　* @param string $path&lt;br /&gt;　* @param string $prefix Unused&lt;br /&gt;　* @return void&lt;br /&gt;　*/&lt;br /&gt;　public function addBasePath($path, $prefix = &#39;Zend_View&#39;) {&lt;br /&gt;　　return $this-&gt;setScriptPath($path);&lt;br /&gt;　}&lt;br /&gt;&lt;br /&gt;　/**&lt;br /&gt;　* 変数をテンプレートに代入します&lt;br /&gt;　*&lt;br /&gt;　* @param string $key 変数名&lt;br /&gt;　* @param mixed $val 変数の値&lt;br /&gt;　* @return void&lt;br /&gt;　*/&lt;br /&gt;　public function __set($key, $val) {&lt;br /&gt;　　$this-&gt;_smarty-&gt;assign($key, $val);&lt;br /&gt;　}&lt;br /&gt;&lt;br /&gt;　/**&lt;br /&gt;　* empty() や isset() のテストが動作するようにします&lt;br /&gt;　*&lt;br /&gt;　* @param string $key&lt;br /&gt;　* @return boolean&lt;br /&gt;　*/&lt;br /&gt;　public function __isset($key) {&lt;br /&gt;　　return (null !== $this-&gt;_smarty-&gt;get_template_vars($key));&lt;br /&gt;　}&lt;br /&gt;&lt;br /&gt;　/**&lt;br /&gt;　* オブジェクトのプロパティに対して unset() が動作するようにします&lt;br /&gt;　*&lt;br /&gt;　* @param string $key&lt;br /&gt;　* @return void&lt;br /&gt;　*/&lt;br /&gt;　public function __unset($key) {&lt;br /&gt;　　$this-&gt;_smarty-&gt;clear_assign($key);&lt;br /&gt;　}&lt;br /&gt;&lt;br /&gt;　/**&lt;br /&gt;　* 変数をテンプレートに代入します&lt;br /&gt;　*&lt;br /&gt;　* 指定したキーを指定した値に設定します。あるいは、&lt;br /&gt;　* キー =&gt; 値 形式の配列で一括設定します&lt;br /&gt;　*&lt;br /&gt;　* @see __set()&lt;br /&gt;　* @param string|array $spec 使用する代入方式 (キー、あるいは キー =&gt; 値 の配列)&lt;br /&gt;　* @param mixed $value (オプション) 名前を指定して代入する場合は、ここで値を指定します&lt;br /&gt;　* @return void&lt;br /&gt;　*/&lt;br /&gt;　public function assign($spec, $value = null) {&lt;br /&gt;　　if (is_array($spec)) {&lt;br /&gt;　　　$this-&gt;_smarty-&gt;assign($spec);&lt;br /&gt;　　　return;&lt;br /&gt;　　}&lt;br /&gt;&lt;br /&gt;　　$this-&gt;_smarty-&gt;assign($spec, $value);&lt;br /&gt;　}&lt;br /&gt;&lt;br /&gt;　/**&lt;br /&gt;　* 代入済みのすべての変数を削除します&lt;br /&gt;　*&lt;br /&gt;　* Zend_View に {@link assign()} やプロパティ&lt;br /&gt;　* ({@link __get()}/{@link __set()}) で代入された変数をすべて削除します&lt;br /&gt;　*&lt;br /&gt;　* @return void&lt;br /&gt;　*/&lt;br /&gt;　public function clearVars() {&lt;br /&gt;　　$this-&gt;_smarty-&gt;clear_all_assign();&lt;br /&gt;　}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;　* テンプレートを処理し、結果を出力します&lt;br /&gt;　*&lt;br /&gt;　* @param string $name 処理するテンプレート&lt;br /&gt;　* @return string 出力結果&lt;br /&gt;　*/&lt;br /&gt;　public function render($name) {&lt;br /&gt;　　return $this-&gt;_smarty-&gt;fetch($name);&lt;br /&gt;　}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;(2) Bootstrapでビューを初期化する際に、 Zend_View_Smartyのインスタンスを生成しフレームワークで使用するビューとして設定する。&lt;br /&gt;&lt;pre class=&#39;brush:php;&#39;&gt;&lt;br /&gt;class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {&lt;br /&gt;　public function _initView() {&lt;br /&gt;　　// application.iniにSmaty使用時に必要な設定を行う。&lt;br /&gt;　　$options = new Zend_Config($this-&gt;getOptions());&lt;br /&gt;　　$config = $options-&gt;view-&gt;smarty-&gt;toArray();&lt;br /&gt;　　$view = new Zend_View_Smarty($config[&#39;script_path&#39;], $config);&lt;br /&gt;　　$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(&#39;ViewRenderer&#39;);&lt;br /&gt;　　$viewRenderer-&gt;setView($view)&lt;br /&gt;　　　-&gt;setViewBasePathSpec($view-&gt;getEngine()-&gt;template_dir)&lt;br /&gt;　　　-&gt;setViewScriptPathSpec(&#39;:controller/:action.:suffix&#39;)&lt;br /&gt;　　　-&gt;setViewScriptPathNoControllerSpec(&#39;:action.:suffix&#39;)&lt;br /&gt;　　　-&gt;setViewSuffix(&#39;tpl&#39;);&lt;br /&gt;　}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;(3) application.iniの設定&lt;br /&gt;view.smarty.cache_dir = APPLICATION_PATH &quot;/views/cache/&quot;&lt;br /&gt;view.smarty.compile_dir = APPLICATION_PATH &quot;/views/templates_c&quot;&lt;br /&gt;view.smarty.script_path = APPLICATION_PATH &quot;/views/templates&quot;&lt;br /&gt;&lt;br /&gt;(4) Smartyテンプレートの配置&lt;br /&gt;以下の場所に配置する事により、対応するコントローラー/アクションが実行されるとSmartyテンプレートが実行される。&lt;br /&gt;APPLICATION_PATH/views/template/{コントローラー}/{アクション}.tpl</content><link rel='replies' type='application/atom+xml' href='http://yanagawadon.blogspot.com/feeds/1458485036650700079/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/zendframeworksmarty.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/1458485036650700079'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/1458485036650700079'/><link rel='alternate' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/zendframeworksmarty.html' title='ZendFrameworkのテンプレートエンジンをSmartyに切替える'/><author><name>柳川丼</name><uri>http://www.blogger.com/profile/02045178650595422120</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8406651269900027144.post-4106528917184863323</id><published>2011-11-19T15:44:00.005+09:00</published><updated>2011-11-19T16:54:00.750+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><category scheme="http://www.blogger.com/atom/ns#" term="Twitter"/><title type='text'>Twitterの相互フォローを自動管理する</title><content type='html'>&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;Twitterの相互フォローを自動的に行いたい場合、&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;  ;font-family:&#39;lucida grande&#39;;font-size:small;&quot;&gt;以下のようなPHPプログラムを１時間に一回程度の頻度で実行させる。&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;$screen_name = &#39;hogehoge&#39;; // 自身のTwitterアカウント&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;require_once(&#39;HTTP/OAuth/Consumer.php&#39;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;require_once(&#39;Services/Twitter.php&#39;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;$rows = array();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;try {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;　$twitter = new Services_Twitter();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;　$oauth = new HTTP_OAuth_Consumer(consumer_key, consumer_secret, auth_token, token_secret);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;　$twitter-&amp;gt;setOAuth($oauth);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;　$followers = $twitter-&amp;gt;followers-&amp;gt;ids(array(&#39;screen_name&#39; =&amp;gt; $screen_name));&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;　$friends = $twitter-&amp;gt;friends-&amp;gt;ids(array(&#39;screen_name&#39; =&amp;gt; $screen_name));&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;　// 削除ユーザー（自分がフォーロしていて相手がフォローしていないユーザー）&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;　$rows = array_diff($friends-&amp;gt;ids, $followers-&amp;gt;ids);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;　foreach($rows as $row) {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;　　$user = $twitter-&amp;gt;users-&amp;gt;show(array(&#39;user_id&#39; =&amp;gt; $row));&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;//　$twitter-&amp;gt;statuses-&amp;gt;update(sprintf(&quot;@%s さいなら〜。&quot;, $user-&amp;gt;screen_name));&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;　　$twitter-&amp;gt;friendships-&amp;gt;destroy(array(&#39;user_id&#39; =&amp;gt; $row));&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;　}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;　// 追加ユーザー（相手がフォローしていて自分がフォローしていないユーザー）&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;  ;font-family:&#39;lucida grande&#39;;font-size:small;&quot;&gt;　$rows = array_diff($followers-&amp;gt;ids, $friends-&amp;gt;ids);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;　foreach($rows as $row) {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;　　$user = $twitter-&amp;gt;users-&amp;gt;show(array(&#39;user_id&#39; =&amp;gt; $row));&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;　　$twitter-&amp;gt;friendships-&amp;gt;create(array(&#39;user_id&#39; =&amp;gt; $row));&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;//　$twitter-&amp;gt;statuses-&amp;gt;update(sprintf(&quot;@%s こんにちは〜。&quot;, $user-&amp;gt;screen_name));&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;　}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;} catch (Exception $e) {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;  ;font-family:&#39;lucida grande&#39;;font-size:small;&quot;&gt;　echo $e-&amp;gt;getMessage();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:85%;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yanagawadon.blogspot.com/feeds/4106528917184863323/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/twitter.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/4106528917184863323'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/4106528917184863323'/><link rel='alternate' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/twitter.html' title='Twitterの相互フォローを自動管理する'/><author><name>柳川丼</name><uri>http://www.blogger.com/profile/02045178650595422120</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8406651269900027144.post-2836884251442212594</id><published>2011-11-19T15:08:00.006+09:00</published><updated>2011-11-26T00:23:50.345+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><category scheme="http://www.blogger.com/atom/ns#" term="Twitter"/><title type='text'>Google Newsから取得した最新ニュースをTwitterでつぶやく</title><content type='html'>&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;lucida grande&#39;;font-size:100%;&quot;&gt;PHPの例。実際には二重投稿チェック処理等の実装が必要。&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;pre class=&#39;brush:php;&#39;&gt;$xml = new SimpleXMLElement(&quot;http://news.google.com/news?hl=ja&amp;ned=us&amp;ie=UTF-8&amp;oe=UTF-8&amp;output=atom&amp;topic=h&quot;, 0, true);&lt;br /&gt;&lt;br /&gt;foreach($xml-&gt;entry as $entry) {&lt;br /&gt;　$link = (array)$entry-&gt;link;&lt;br /&gt;　urlshorter($link[&quot;@attributes&quot;][&quot;href&quot;]);&lt;br /&gt;　tweet((string)$entry-&gt;title, $url)&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// Twitterでつぶやく&lt;br /&gt;function tweet($content, $url) {&lt;br /&gt;　try {&lt;br /&gt;　　$twitter = new Services_Twitter();&lt;br /&gt;　　$oauth = new HTTP_OAuth_Consumer(consumer_key, consumer_secret, auth_token, token_secret);&lt;br /&gt;　　$twitter-&gt;setOAuth($oauth);&lt;br /&gt;　　$statuses = sprintf(&quot;%s %s&quot;, $content, $url);&lt;br /&gt;　　$twitter-&gt;statuses-&gt;update($statuses);&lt;br /&gt;　} catch (Exception $e) {&lt;br /&gt;　　printf(&quot;%s(%d): %s\n&quot;, __FILE__, __LINE__, $e-&gt;getMessage());&lt;br /&gt;　　exit;&lt;br /&gt;　}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// URL短縮&lt;br /&gt;function urlshorter($url) {&lt;br /&gt;　$curl = curl_init(&#39;https://www.googleapis.com/urlshortener/v1/url&#39;);&lt;br /&gt;　curl_setopt($curl, CURLOPT_HTTPHEADER, array(&#39;Content-type: application/json&#39;));&lt;br /&gt;　curl_setopt($curl, CURLOPT_POST, 1);&lt;br /&gt;　curl_setopt($curl, CURLOPT_POSTFIELDS, &#39;{&quot;longUrl&quot;:&quot;&#39; . $url . &#39;&quot;}&#39;);&lt;br /&gt;　curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);&lt;br /&gt;　$r = curl_exec($curl);&lt;br /&gt;　curl_close($curl);&lt;br /&gt;&lt;br /&gt;　$d = json_decode($r);&lt;br /&gt;　return $d-&gt;id;&lt;br /&gt;}&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://yanagawadon.blogspot.com/feeds/2836884251442212594/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/google-newstwitter.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/2836884251442212594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8406651269900027144/posts/default/2836884251442212594'/><link rel='alternate' type='text/html' href='http://yanagawadon.blogspot.com/2011/11/google-newstwitter.html' title='Google Newsから取得した最新ニュースをTwitterでつぶやく'/><author><name>柳川丼</name><uri>http://www.blogger.com/profile/02045178650595422120</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>