jeudi 30 mars 2017

how to continue requesting when first response is not accepted in php?

I am a new for using Guzzle package i want to send data via web api when response coming with status OK or NOT i do some action otherwise status equal waiting i request again after 5second or status equal not yet sleep for 30 second. this is my code

$client = new Client();
  $headers= [
            'Accept' => 'application/x-www-form-urlencoded',
            'Content-Type' => 'application/x-www-form-urlencoded',
        ];
        $body = [
            'phone2'=>'723457481',
            'amount'=>'200'
        ];
        $url = "http://ift.tt/2oBhHH4";

       $response = $client->Request("POST", $url, [
            'handler'  => $stack,
            'headers'=>$headers,
            'form_params'=>$body
        ]);
        $contents = (string) $response->getBody();
       // this $contents can be  status 'ok','not' anything

So how can I send again according response status ? Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire