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
Post a Comment