Answers for "wordpress curl wp remote post timeout error"

PHP
0

wordpress curl wp remote post timeout error

//this timeout error comes when request takes much time ti fetch response
//in such cases, simply use curl instead of wordpress request functions like wp_remote_post($url) or wp_remote_request($url)

$ch = curl_init();
 	curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arguments));
    $response = curl_exec($ch);
    $result = json_decode($response);
    curl_close($ch); // Close the connection
 return $result;
Posted by: Guest on April-28-2022

Browse Popular Code Answers by Language