cURL Error (28) - troubleshoot JSON request / PHP
$10-30 USD
Paid on delivery
Hi,
I have a PHP program that uses JSON and cURL to request data to be written to a txt file. When I execute it, I am getting the following error:
cURL Error (28): Operation timed out after 201 milliseconds with 0 bytes received
Here is my code:
if (!isset($_GET['foo'])) {
// Client
$pIds = array("All");
$data = array("apiToken" => "apitoken-3D", "productIds" => $pIds);
$data_string = json_encode($data);
//echo $data_string;
$ch = curl_init('http://myurl/WriteProductData');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 200);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$data = curl_exec($ch);
//var_dump(json_decode($data, true));
$curl_errno = curl_errno($ch);
$curl_error = curl_error($ch);
curl_close($ch);
if ($curl_errno > 0) {
echo "cURL Error ($curl_errno): $curl_error\n";
} else {
echo "Data received: $data\n";
} else {
// Server
sleep(10);
echo "Done.";
}
Above is not the real API key, etc. but just wanted you to see the code.
Please advise how to troubleshoot this, and what to do to resolve this issue. We can make adjustments on the server if necessary. Please respond back and let me know how much experience you have with PHP/Curl.
THANKS!
Project ID: #5716370
About the project
21 freelancers are bidding on average $28 for this job
Hello, With 99% completion rate, 650+ successfully completed projects, and a 5.00 reputation (maximum possible, 5.0) (Yes, not even 4.99 average rating, can be verified on my profile page !!)... you can never go wro More
skilled in curl, i can do the fix for you. skilled in curl, i can do the fix for you. skilled in curl, i can do the fix for you.
Hi, I can get this debug and working for you with perfection and on time. I am a Software Developer with over 4.5 years of experience in LAMP technology. I have worked with various technologies like CakePHP, Ma More
Hi, I have over 13 years of Experience in software design, development and implementation of various commercial applications in Client/Server environment, Web and ERP applications using C# 1.1/2.0/3.5, ASP.Net, VB.N More
A server administrator with 7 years of experience and a PHP developer with over 10 years of experience are available here to troubleshoot this issue. Please share the details if interested.
Your problem is that cURL is set to timeout after 200 milliseconds which is far to short. Remove this line totally curl_setopt($ch, CURLOPT_TIMEOUT_MS, 200); or set the value to something higher than 200. I personall More
Hi! I have had a similar problem with my curl scripts. If you have Teamviewer handy I can begin working on this for you right now. Thanks, George
Hello, I found your job post and I’m very interested in your project. As an experienced PHP, Curl. You can check my profile to see my project about curl I think you’ll find I have the skills you’re looking for. I More
Hello I have done many CURL POST PHP Script. Seems that there is only 1 line is to be added to fix ur issue. So give me UR Original URL. I will show you it is working. If its works then paid me else no Than More
I have worked on a PHP project before. All i need is a detailed information about the work to be done and ill get the job done. Given this opportunity i wont disappoint you.
I see from the code, then Try changing your code line curl_setopt ($ ch, CURLOPT_TIMEOUT_MS, 200); Change the variable value CURLOPT_TIMEOUT_MS is 300