sendPhoto() public method

Use this method to send photos. On success, the sent Message is returned.
Values inside $content:
Parameters Type Required Description
chat_id Integer Yes Unique identifier for the message recipient — User or GroupChat id
photo InputFile or String Yes Photo to send. You can either pass a file_id as String to resend a photo that is already on the Telegram servers, or upload a new photo using multipart/form-data.
caption String Optional Photo caption (may also be used when resending photos by file_id).
reply_to_message_id Integer Optional If the message is a reply, ID of the original message
reply_markup ReplyKeyboardMarkup or >ReplyKeyboardHide or ForceReply Optional Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
\param $content the request parameters as array \return the JSON Telegram's reply
public sendPhoto ( array $content )
$content array
Exemplo n.º 1
1
            $reply = "Private Chat";
        }
        // Create option for the custom keyboard. Array of array string
        $option = array(array("A", "B"), array("C", "D"));
        // Get the keyboard
        $keyb = $telegram->buildKeyBoard($option);
        $content = array('chat_id' => $chat_id, 'reply_markup' => $keyb, 'text' => $reply);
        $telegram->sendMessage($content);
    }
    if ($text == "/git") {
        $reply = "Check me on GitHub: https://github.com/Eleirbag89/TelegramBotPHP";
        // Build the reply array
        $content = array('chat_id' => $chat_id, 'text' => $reply);
        $telegram->sendMessage($content);
    }
    if ($text == "/img") {
        // Load a local file to upload. If is already on Telegram's Servers just pass the resource id
        $img = curl_file_create('test.png', 'image/png');
        $content = array('chat_id' => $chat_id, 'photo' => $img);
        $telegram->sendPhoto($content);
        //Download the file just sended
        $file_id = $message["photo"][0]["file_id"];
        $file = $telegram->getFile($file_id);
        $telegram->downloadFile($file["file_path"], "./test_download.png");
    }
    if ($text == "/where") {
        // Send the Catania's coordinate
        $content = array('chat_id' => $chat_id, 'latitude' => "37.5", 'longitude' => "15.1");
        $telegram->sendLocation($content);
    }
}