0

Hi i have looking for the correct answer for this and none works for my

Want to send a poll in telegram Api but I think it will be the same in any other command whit a nested array

well I'm working o this

$path = "https://api.telegram.org/botMyBotEtc...";
$command="/sendpoll";
$chatId="SomeID";
$data = array(
    'chat_id'=>$chatId,
    'question'=>'This is a poll ?',
    'answers' => array (
        'Yes',
        'No',
        'Maybe',
        ),
    'is_anonymous'=>false,
    'allows_multiple_answers'=>false,
    'type'=>'regular'
);

$data_string = json_encode($data);

$curl = curl_init(); 
curl_setopt_array($curl, array(
        CURLOPT_URL => $path.$command,
        CURLOPT_RETURNTRANSFER => true, 
        CURLOPT_POST => true,
        CURLOPT_CUSTOMREQUEST => "POST", 
        CURLOPT_POSTFIELDS => $data_string,
    )
);

$response =  curl_exec($curl); 
$json_data = json_decode($response); 
$json_print=json_encode($json_data, JSON_PRETTY_PRINT);
error_log($json_print, 0);
curl_close($curl);

but when it's executed i get the "Bad Request: can't parse options JSON object"

PHP message: {
    "ok": false,
    "error_code": 400,
    "description": "Bad Request: can't parse options JSON object"
}
PHP message: {
        "chat_id":"SomeID",
        "question":"This is a poll ?",
        "answers": "Yes","No","Maybe"],
        "is_anonymous":false,
        "allows_multiple_answers":false,
        "type":"regular"
}"
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
TheDi
  • 1
  • 2

0 Answers0