php - Adding a retry condition using wp_remote_post -


i using following code posting api

$post_response = wp_remote_post(   $url,   array(     "method" => "post",     "timeout" => 45,     "headers" =>  $headers,      "body" => $jsondata,     "sslverify" => false   ) ); 

here have added timeout of 45 seconds, since api takes long time return output server.

can tell me alternative way of adding retry condition send post in case api takes long send output should able trace responses also.

you can use;

while(1) {     $post_response = wp_remote_post(       $url,       array(         "method" => "post",         "timeout" => 45,         "headers" =>  $headers,          "body" => $jsondata,         "sslverify" => false       )     );     if (!empty($post_response) && $post_response["response"]["code"] == 200) {         break;     }     echo "post request failed: " .  $post_response["response"]["message"]; } 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -