Em có hàm POST request như sau:
function sendAPI($url, $data){ $ch = curl_init($url); $jsonDataEncoded = $data; curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); if(!empty($input['entry'][0]['messaging'][0]['message'])){ $result = curl_exec($ch); } }
Rồi em gọi nó:
sendAPI($someUrl, $someData);
thì nó không chạy, còn em dùng trực tiếp:
$ch = curl_init($someUrl); $jsonDataEncoded = $someData; curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); if(!empty($input['entry'][0]['messaging'][0]['message'])){ $result = curl_exec($ch); }
thì nó lại chạy bình thường. Ai giúp em với ạ :((

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?