我使用的是来自github的python和python unsplash api(下面的链接)。我正试图找到一种方法通过api获取随机照片的URL,但却遇到了照片ID。我不知道如何找到相应的URL,以与使用命令时返回的照片ID相匹配(如下面的代码所示)
没有出现任何错误消息
Python-Unsplash GitHub API Documentation
Normal Unsplash API Documentation
from unsplash.api import Api
from unsplash.auth import Auth
client_id = "#this would normally be my access key" #authenticating
client_secret = "" #my profile
redirect_uri = ""
code = ""
auth = Auth(client_id, client_secret, redirect_uri, code=code)
api = Api(auth)
img= api.photo.random(orientation = 'landscape' ) #gets id of random photo
print(img)
print(api.photo.get('wzfOt1uwzxc')) #I was hoping this would return URL but doesn't
引用的Python API似乎是非正式的。根据他们的文档,不可能用ID检索URL
尝试改用非Flash REST API。根据他们的documentation,您应该能够在响应中查看URL
相关问题 更多 >
编程相关推荐