I am trying to get the JSON response from twitter oEmbed API using python's requests library. The tweet ID that I tried to pass in was 1221064170248065024
. And here's the code that I have used for making a request to the API.
import requests
tweet_id = '463440424141459456'
embReqUrl = 'https://publish.twitter.com/oembedurl=https://twitter.com/Interior/status/'+tweet_id
embResp = requests.post(embReqUrl)
After that, when I go for checking the HTTP status of my response using embResp.status_code
, it is giving me a 405
status code. What's the right way to do it?
Please help
You’ve used a POST method, but this API expects a GET.
embResp = requests.get(embReqUrl)
print(embResp.status_code)
print(embResp.json())