Php/fuelphp/httprequest
提供: 初心者エンジニアの簡易メモ
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