facebook twitter hatena line email

「Php/fuelphp/httprequest」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
 
(同じ利用者による、間の1版が非表示)
行27: 行27:
  
 
その他はこちら
 
その他はこちら
             [url] => http://www.hogehoge.com<br />
+
             [url] => http://www.yahoo.com
             [content_type] => text/html; charset=UTF-8<br />
+
             [content_type] => text/html; charset=UTF-8
             [http_code] => 200<br />
+
             [http_code] => 200
             [header_size] => 910<br />
+
             [header_size] => 910
             [request_size] => 100<br />
+
             [request_size] => 100
             [filetime] => -1<br />
+
             [filetime] => -1
             [ssl_verify_result] => 0<br />
+
             [ssl_verify_result] => 0
             [redirect_count] => 1<br />
+
             [redirect_count] => 1
             [total_time] => 0.079887<br />
+
             [total_time] => 0.079887
             [namelookup_time] => 0.001401<br />
+
             [namelookup_time] => 0.001401
             [connect_time] => 0.003478<br />
+
             [connect_time] => 0.003478
             [pretransfer_time] => 0.00348<br />
+
             [pretransfer_time] => 0.00348
             [size_upload] => 0<br />
+
             [size_upload] => 0
             [size_download] => 50500<br />
+
             [size_download] => 50500
             [speed_download] => 632142<br />
+
             [speed_download] => 632142
             [speed_upload] => 0<br />
+
             [speed_upload] => 0
             [download_content_length] => 178<br />
+
             [download_content_length] => 178
             [upload_content_length] => 0<br />
+
             [upload_content_length] => 0
             [starttransfer_time] => 0.06756<br />
+
             [starttransfer_time] => 0.06756
             [redirect_time] => 0.006192<br />
+
             [redirect_time] => 0.006192
             [redirect_url] => <br />
+
             [redirect_url] =>  
             [primary_ip] => 210.129.120.44<br />
+
             [primary_ip] => 210.129.120.44
             [certinfo] => Array<br />
+
             [certinfo] => Array
                 (<br />
+
                 (
                 )<br />
+
                 )
  <br />
+
   
             [primary_port] => 80<br />
+
             [primary_port] => 80
             [local_ip] => xxx.xxx.xxx.xxx<br />
+
             [local_ip] => xxx.xxx.xxx.xxx
             [local_port] => 44409<br />
+
             [local_port] => 44409

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