我想知道如何使用python运行以下cURL请求(我正在使用Jupyter notebook):
curl -i -X GET "https://graph.facebook.com/{graph-api-version}/oauth/access_token?
grant_type=fb_exchange_token&
client_id={app-id}&
client_secret={app-secret}&
fb_exchange_token={your-access-token}"我看过一些类似的问题和答案,建议使用"requests.get",但我是一个完全的python新手,不确定如何组织整个请求的语法,包括id,secret和token元素。任何帮助都将不胜感激。
谢谢!
发布于 2021-08-26 09:20:28
您可以使用一些在python中运行命令的库,比如subprocess。例如:subprocess.run(["curl", "google.com"])
发布于 2021-08-26 09:23:56
不需要使用curl。使用下面的代码
import requests
graph_api_version = 'a'
app_id = 'b'
app_secret = 'c'
your_access_token = 'd'
url = f"https://graph.facebook.com/{graph_api_version}/oauth/access_token?grant_type=fb_exchange_token&client_id={app_id}&client_secret={app_secret}&fb_exchange_token={your_access_token}"
r = requests.get(url)发布于 2021-08-26 10:01:45
在这里立即将您的Curl请求转换为Python:https://curl.trillworks.com/
https://stackoverflow.com/questions/68935814
复制相似问题