英文:
Google Slides - using api a post in a web link
问题
有没有一种方法可以通过编程方式“发布到网络...”Google幻灯片演示?
与表格不同,幻灯片需要额外的参数进行发布。我正在尝试找出如何通过编程方式推送演示文稿并获取已发布的URL。
非常感谢任何帮助。
`presentation = service.presentations().get(
presentationId=presentation_id
).execute()
print(presentation)
print(presentation)
patched_revision = {
'published': True,
'publishAuto': True,
'publishedOutsideDomain': True
}
resq = service.permissions().update(
fileId=id_present,
body=patched_revision
).execute()`
`presentation = service.presentations().get(
presentationId=presentation_id
).execute()
print(presentation)
print(presentation)
patched_revision = {
'published': True,
'publishAuto': True,
'publishedOutsideDomain': True
}
resq = service.permissions().update(
fileId=id_present,
body=patched_revision
).execute()`
权限为:
{
'role': 'reader',
'type': 'anyone',
'withLink': True
}
并使用这些参数也尝试了。
我希望演示文稿可以在以下链接上使用:
"https://docs.google.com/presentation/d/{{ID-PRESENT}}/pub"
英文:
Is there a way to "Publish to the Web..." a Google Slides presentation programmatically?
Unlike Sheets, Slides takes in additional parameters for publishing. I am trying to figure out how to push the presentation programmatically and get the published URL
Any help is greatly appreciated.
` presentation = service.presentations().get(
presentationId=presentation_id
).execute()
print(presentation)
# print(presentation)
patched_revision = {
'published': True,
'publishAuto': True,
'publishedOutsideDomain': True
}
resq = service.permissions().update(
fileId=id_present,
body=patched_revision
).execute()`
presentation = service.presentations().get(
presentationId=presentation_id
).execute()
print(presentation)
# print(presentation)
patched_revision = {
'published': True,
'publishAuto': True,
'publishedOutsideDomain': True
}
resq = service.permissions().update(
fileId=id_present,
body=patched_revision
).execute()`
permission = {
'role': 'reader',
'type': 'anyone',
'withLink': True
}
and with such parameters also tried
I want the presentation to be available at the link
"https://docs.google.com/presentation/d/{{ID-PRESENT}}/pub"
答案1
得分: 1
修改后的脚本:
service = build("drive", "v3", credentials=creds) # 请使用您的客户端。
id_present = "###" # 请设置您的Google幻灯片文件ID。
service.revisions().update(fileId=id_present, body={"published": True, "publishedOutsideDomain": True, "publishAuto": True}, revisionId=1).execute()
url = f'https://docs.google.com/presentation/d/{id_present}/pub'
print(url)
- 运行此脚本时,
url
可以作为已发布到Web的Google幻灯片访问。
参考:
英文:
In your situation, how about the following modification?
Modified script:
service = build("drive", "v3", credentials=creds) # Please use your client.
id_present = "###" # Please set your file ID of Google Slide.
service.revisions().update(fileId=id_present, body={"published": True, "publishedOutsideDomain": True, "publishAuto": True}, revisionId=1).execute()
url = f'https://docs.google.com/presentation/d/{id_present}/pub'
print(url)
- When this script is run,
url
can be accessed as the Web-published Google Slide.
Reference:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论