成果報告があります。
CakePHP でさくっと報告しちゃいましょう。
CakePHPのコアユーティリティライブラリの HttpSocket クラスを使えば簡単です。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App::import('Core', 'HttpSocket'); | |
$httpSocket = new HttpSocket(); | |
// http://example.com?params1=values1 | |
// $response には httpレスポンスの body 部分が返ってくる | |
// リクエスト先で OK とテキスト出力されているなら $response の中身は OK になる。 | |
$response = $httpSocket->get('http://example.com', array( | |
'params1' => 'values1', | |
)); |
ね?簡単でしょ?
GET の例ですが、もちろん POST もできます。
BASIC認証なんかもいけます。
参考:
HttpSocket :: コアユーティリティライブラリ :: マニュアル :: 1.3コレクション
http://book.cakephp.org/ja/view/1517/HttpSocket
このクラスの存在知らなくて、
Zend_Http_Client 使おうとしたのは内緒。