You pass the wrong url parameters.
Instead off sendPhoto-Fchat_id
use the ?
and &
sign. If you wish to add multiple parameters; take a look at Querystring Array Parameters in Python using Requests
sendPhoto?chat_id=123&photo=somelink
To answer the question, you can use the requests library like this:
import requests
from requests.exceptions import HTTPError
url="https://api.telegram.org/bot<MY-TOKEN>/sendPhoto?chat_id=<MY-CHAT-ID>&photo=http://via.placeholder.com/100x100"
try:
response = requests.get(url)
# If the response was successful, no Exception will be raised
response.raise_for_status()
except HTTPError as http_err:
print(f'HTTP error occurred: {http_err}') # Python 3.6
except Exception as err:
print(f'Other error occurred: {err}') # Python 3.6
else:
print('Success!')