Google APIs Client Library for PHP 0.6.7 の要件では、 PHP5.3 以上 とあるが、CentOS4 centosplus のパッケージはPHP5.1.6 なので、PHP本家のサイト から、5.3.27をダウンロード、make install。

すでにCentOS4のリポジトリはメンテナンスされていないので、Base.repoをココ のように書き換える必要がある。


しかしながら、
"Unable to sign data"
なる例外が出てしまい、中断してしまう。

問題の部分のソースが、



  1.  
  2. function sign($data) {
  3. if(version_compare (PHP_VERSION, '5.3.0') < 0) {
  4. throw new Google_AuthException(
  5. "PHP 5.3.0 or higher is required to use service accounts.");
  6. }
  7. if (!openssl_sign ($data, $signature, $this->privateKey, "sha256")) {
  8. throw new Google_AuthException("Unable to sign data");
  9. }
  10. return $signature;
  11. }

openssl_sign() 関数の "sha256" が存在していないようだ。
あちこちググると、CentOS4の openssl0.9.7 が sha256に対応していないようなのである。

なので、Openssl本家サイト からダウンロードして



  1. ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl shared


あとは、make, make install

そのあと、大事なことだが、/etc/ld.so.confに、/usr/local/openssl/lib を追加し、ldconfig を実行する。



更にPHPを再コンパイルする。



  1. ./configure --prefix=/usr/local/php-5.3.27 --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --enable-mbstring --with-curl --with-openssl=/usr/local/openssl
  2.  

適宜オプションを追加!!

これで動くはずです!

すごく久ぶりの更新です。

ガラケー用のviewを作成する必要があり、CakePHP2.3.8 と CakeKtaiLibrary 開発を開始した。
ちなみにガラケーのviewは、prefix routingを使用した。


  1. Configure::write('Routing.prefixes', array ('m'));


本番のFastserverへアップしチェックを開始。

特に問題もないし、エラーも出ないのだが、なんか違和感が。。。。

「フッダーがないぞ・・・」
正確には最下部のメニューリストの途中で切れている。

問題は、Docomoでのみ発生するので
use_trans_sidが問題なのだろうと考えたが、
途切れる理由にならない。


いろいろ調べたところ、CakePHPがContent-Lengthを出力しているため、session IDを付加した増加したbyte分、途切れてしまっていることが判明した。

開発用のサーバーでは問題なかったのに、fastserverで問題が起こった理由もわからないままだが対策としては、


  1. public function beforeRender() {
  2.  
  3. if ( is_object ($this->Ktai) && $this->Ktai->is_imode() ) {
  4. $this->response->header('Content-Length', false);
  5. }
  6. }


で解決しました。




PHPのstream_contextで、squid経由でHTTPアクセスするときのメモ。


$opt = array (
'http' => array (
'proxy' => 'tcp://192.168.0.1:9999',
'user_agent' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)',
'method' => 'GET',
'protocol_version' => '1.1'));
$context = stream_context_create ($opt);
$page = file_get_contents ($url, false, $context);


192.168.0.1は、squid稼働中のホスト。

file_get_contentsは失敗し、自動的に定義される$http_response_headerは、

HTTP/1.0 400 Bad Request
X-Squid-Error: ERR_INVALID_REQ 0

こんな感じの内容になる。

squidのログを見ると、subnet内のホストへのアクセスし、失敗が記録されている。


$opt = array (
'http' => array (
'request_fulluri' => true,
'proxy' => 'tcp://192.168.0.1:9999',
'user_agent' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)',
'method' => 'GET',
'protocol_version' => '1.1'));
$context = stream_context_create ($opt);
$page = file_get_contents ($url, false, $context);

request_fulluriを追加すればOK!!