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 -

android - IBM Worklight 6.1 [Application Error] There was a network error (file:///android_asset/www/index.html) -