php - Telegram gives Empty reply from server while trying to send some images with cUrl -


i made function in php uses multipart/form-data , curl send documents via telegram's senddocument api. here documentation

specifically, use send .png file documents, doesn't work 2 or 3 images in total, of hundreds successful. error returned curl_error "empty reply server". dont' know why , how comes images. here have 1 of those

this function use:

function spng($chat_id, $nome, $fnome = 'justforwardme.png') { global $api; define('botapi','https://api.telegram.org/'.$api.'/');  $cfile = new curlfile($nome, 'image/png', $fnome);     $data = [         'chat_id' => $chat_id ,          'document' => $cfile         ];      $ch = curl_init(botapi.'senddocument');     if ($ch===false) return array(false, 'unable set url');     curl_setopt($ch, curlopt_httpheader, array(               'content-type:multipart/form-data'     ));     curl_setopt($ch, curlopt_returntransfer, 1);     curl_setopt($ch, curlopt_post, 1);     curl_setopt($ch, curlopt_postfields, $data);     curl_setopt($ch, curlopt_ssl_verifypeer, false);     $result = curl_exec($ch);     if ($result) $error = 'none'; else $error = curl_error($ch);     curl_close($ch);     return array($result, $error); } 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -