-3

Can anyone solve this problem using GuzzleHttp? I want to display the $reportid in controller, but I'm stuck at the moment.

//Select Data For SDO Homepage Report
public function SDOHomepage(){
    $client = new \GuzzleHttp\Client();
    $url=WEBSERVICE_URL;
    //Response 1
    $response1=$client->request('POST', $url,['form_params'=>['tag'=>'selectSDOHomepage']]);

    //$body = $response1->getBody();
    //$reportid = $body['ReportID'];

    //Response 2
    $response2=$client->request('POST', $url,['form_params'=>['tag'=>'sdoCountReply','ReportID'=>$reportid]]);

    $data1=json_decode($response1->getBody()->getContents(),true);
    $data2=json_decode($response2->getBody()->getContents(),true);

    //Return Data
    return view('SDOHomepage',['SDO_All'=>$data1,'SDO_Reply_Count'=>$data2]);   
}

1 Answers1

0

Are you perhaps missing this?

$body = $response1->getBody();
$reportid = $body['ReportID'];

You may or may not need to do something else like json_decode.

Greg
  • 81
  • 5
  • thanks for the answer. but i have an error it says (Cannot use object of type GuzzleHttp\Psr7\Stream as array) maybe another method should I use here? – Regie Averos Jul 11 '18 at 02:09
  • https://stackoverflow.com/questions/30549226/guzzlehttp-how-get-the-body-of-a-response-from-guzzle-6 – Greg Jul 12 '18 at 12:37