「Php/fuelphp/httprequest」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→request詳細取得) |
|||
行27: | 行27: | ||
その他はこちら | その他はこちら | ||
− | [url] => http://www. | + | [url] => http://www.yahoo.com |
[content_type] => text/html; charset=UTF-8 | [content_type] => text/html; charset=UTF-8 | ||
[http_code] => 200 | [http_code] => 200 |
2015年10月26日 (月) 01:20時点における最新版
postサンプル
$params = array( 'id' => 'hoge', ); $request = \Request::forge($url, 'curl'); $request->set_method('post'); $request->set_params($params); $request->execute(); $response = $request->response(); print $response->status; // 200 print $response->body(); // html
生jsonデータをpostしたい場合
$json = json_encode($params); $request = \Request::forge($url, 'curl'); $request->set_method('post'); $request->set_mime_type('json'); $request->set_params($json); $request->execute(); $response = $request->response(); print $response->status; // 200 print nl2br(print_r($response->body(),1)); // html
request詳細取得
urlを取得、リダイレクトした場合は、その先のurlが表示される
echo $request->response_info('url');
その他はこちら
[url] => http://www.yahoo.com [content_type] => text/html; charset=UTF-8 [http_code] => 200 [header_size] => 910 [request_size] => 100 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 1 [total_time] => 0.079887 [namelookup_time] => 0.001401 [connect_time] => 0.003478 [pretransfer_time] => 0.00348 [size_upload] => 0 [size_download] => 50500 [speed_download] => 632142 [speed_upload] => 0 [download_content_length] => 178 [upload_content_length] => 0 [starttransfer_time] => 0.06756 [redirect_time] => 0.006192 [redirect_url] => [primary_ip] => 210.129.120.44 [certinfo] => Array ( ) [primary_port] => 80 [local_ip] => xxx.xxx.xxx.xxx [local_port] => 44409