Google Slides – 使用 API 在网页链接中发布一篇文章

huangapple go评论82阅读模式
英文:

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:

huangapple
  • 本文由 发表于 2023年7月11日 06:07:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/76657627.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定