Archive

For the PHP category

memcacheのPHP Warningがでた

No Comments

ちょっと、そろそろちょっとしたツールでも作ろうと思い、環境整備に走る。

「PHP 5.3.9」に危険度の高い脆弱性、最新版へのアップデートを

一般社団法人JPCERTコーディネーションセンター(JPCERT/CC)は6日、PHPのバージョン5.3.9に危険度の高い脆弱性が存在するとして、注意喚起を行った。

INTERNET Watch

と、その前に昨日こんな記事が目に止まったので、PHPのバージョンをチェックしてみると、あれれれ?こんなメッセージが出てしまった。

# php -v
PHP Warning:  PHP Startup: memcache: Unable to initialize module
Module compiled with module API=20060613
PHP    compiled with module API=20090626
These options need to match
in Unknown on line 0
PHP Warning:  PHP Startup: apc: Unable to initialize module
Module compiled with module API=20060613
PHP    compiled with module API=20090626
These options need to match
in Unknown on line 0
PHP Warning:  PHP Startup: memcache: Unable to initialize module
Module compiled with module API=20060613
PHP    compiled with module API=20090626
These options need to match
in Unknown on line 0
PHP 5.3.10 (cli) (built: Feb  3 2012 08:20:28)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
#



よくわからん、ということで apc と memcache を uninstall して、再度 install。

# pecl uninstall apc
Unable to remove "extension=apc.so" from php.ini
uninstall ok: channel://pecl.php.net/APC-3.1.6
# sudo -u root pecl install apc
downloading APC-3.1.9.tgz ...
Starting to download APC-3.1.9.tgz (155,540 bytes)
.................................done: 155,540 bytes
54 source files, building
< 中略 >
Build process completed successfully
Installing '/usr/lib64/php/modules/apc.so'
Installing '/usr/include/php/ext/apc/apc_serializer.h'
install ok: channel://pecl.php.net/APC-3.1.9
configuration option "php_ini" is not set to php.ini location
You should add "extension=apc.so" to php.ini
#
# pecl uninstall memcache
Unable to remove "extension=memcache.so" from php.ini
uninstall ok: channel://pecl.php.net/memcache-2.2.6
# sudo -u root pecl install memcache
downloading memcache-2.2.6.tgz ...
Starting to download memcache-2.2.6.tgz (35,957 bytes)
..........done: 35,957 bytes
11 source files, building
< 中略 >
Build process completed successfully
Installing '/usr/lib64/php/modules/memcache.so'
install ok: channel://pecl.php.net/memcache-2.2.6
configuration option "php_ini" is not set to php.ini location
You should add "extension=memcache.so" to php.ini
#
# php -v
PHP 5.3.10 (cli) (built: Feb  3 2012 08:20:28)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
#



正常になってひと安心。

URL短縮にGoo.glを使ってみよう

No Comments

URLの短縮といえば、Twitterで有名になったbit.lyがある。
また、同じbit.lyのj.mpもある。

しかし、Googleも似たようなことをやっており、goo.glがある。
やっているのがGoogleなので、これを使ってみようと思った。

というのも、APIが公開されているので、プログラムからも利用できると思ってのことである。

早速Google apisにて、APIキーの発行を、と思ったらプロジェクトの構築からだった。
とりあえず、GeekWindというプロジェクトにして、進むと簡単にコンソール画面。

Google apis

URL Shortener APIのActivateボタンを押してActivateすると、APIキーが発行された。
というよりも、プロジェクトで1つAPIキーがあって、そのキーを利用できるサービスを選ぶという形のようだ。

で、早速実験。

すると、http://www.geekwind.net/http://goo.gl/dyq1bというURLに短縮された。
プログラムで短縮できるのはいい感じ。

先日作成したTwitterBotに組み込めば、URLも短くして投稿できるようになるのでURL付きでも安心だ。
結構、使えそうである。

今度はPHPでTwitterBotを作ってみた

No Comments

先日、PerlでTwitterに投稿するBotを作ったが、今度はPHPで作ってみた。

ただ、すでにアプリ登録しているものだと何なので、もう1つテスト用のConsumer keyとConsumer secretを発行。
もちろん、アクセス用のTokenも同時に発行した。

それでテスト投稿もしてみた。
きちんと投稿できたので満足。

ところでPHPでのTwitterBotの作成にあたり、PEARのパッケージをいくつかインストールした。
インストールの前に、PEARのアップグレードも行った。

# pear upgrade PEAR
# pear list
Installed packages, channel pear.php.net:
=========================================
Package          Version State
Archive_Tar      1.3.7   stable
Console_Getopt   1.2.3   stable
PEAR             1.9.1   stable
Structures_Graph 1.0.4   stable
XML_RPC          1.5.1   stable
XML_Util         1.2.1   stable
# pear install Net_URL
# pear install Net_URL2-beta
# pear install http_request
# pear install http_request2-0.5.2
# pear install HTTP_OAuth-0.2.2
# pear install Services_Twitter-beta
最終的にこんな感じのパッケージだけで投稿できるようになった。
# pear list
Installed packages, channel pear.php.net:
=========================================
Package          Version State
Archive_Tar      1.3.7   stable
Console_Getopt   1.2.3   stable
HTTP_OAuth       0.2.2   alpha
HTTP_Request     1.4.4   stable
HTTP_Request2    0.5.2   alpha
Net_Socket       1.0.10  stable
Net_URL          1.0.15  stable
Net_URL2         0.3.1   beta
PEAR             1.9.1   stable
Services_Twitter 0.6.3   beta
Structures_Graph 1.0.4   stable
XML_RPC          1.5.1   stable
XML_Util         1.2.1   stable



Blue Taste Theme created by Jabox