Quantcast
Channel: WampServer - WampServer English
Viewing all articles
Browse latest Browse all 3177

cURL is making apache to consume most of the cpu (2 replies)

$
0
0
I'm trying to interact with Whatsapp API using PHP cURL. The code is simple, send a POST request to send a message to a phone. That's it. It works, sends the message without issues. The problem begins after that.

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "[graph.facebook.com];);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode([
'messaging_product' => 'whatsapp',
'to' => '<PHONE_NUMBER_TO_SEND>',
'type' => 'template',
'template' => [
'name' => 'hello_world',
'language' => [
'code' => 'en_US',
],
],
]));
curl_setopt($curl, CURLOPT_HTTPHEADER, [
"Authorization: Bearer <TOKEN>",
'Content-Type: application/json',
]);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
var_dump($response);

Normally Apache does not consume any CPU at all but after I run the code previously showed, it starts to increment the CPU consumption until it reach 80% or more.

After that I need to restart the Apache server.

Is there something I can do to avoid this?

I updated WampServer to the last available update (3.3.2). I'm using Apache 2.4.58, PHP 8.3.0 and MySQL 8.2.0 on a PC Windows 10 Pro Version 22H2. The Apache server is using an SSL instaled with CertBot.

For screenshots you can see this url [stackoverflow.com]

Viewing all articles
Browse latest Browse all 3177

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>