我怎样才能让它工作:嵌入 Twitter 的 Web Intent

发布于 2024-11-16 18:37:56 字数 558 浏览 2 评论 0原文

通常Web Intent用作弹出窗口。据 Twitter 称,它还提供嵌入功能。

“某些网站可能更愿意嵌入不显眼的 Web Intents 弹出式 Javascript 内联或不依赖于 platform.twitter.com。下面的代码段将提供等效的功能,而无需外部依赖。”
该代码段可以在 https://gist.github.com/894540#file_intents.html
请参阅:
http://dev.twitter.com/pages/intents

但是,我不能让这个片段工作。 我将片段(JavaScript)代码复制到一个 html 文件中,并在浏览器中打开它。什么也没发生!我应该怎么做才能让它发挥作用?

Normally Web Intent is used as a pop-up. According to Twitter, it also provides embedding functionality.

"Some sites may prefer to embed the unobtrusive Web Intents pop-up Javascript inline or without a dependency to platform.twitter.com. The snippet below will offer the equivalent functionality without the external dependency."
The snippet can be found at https://gist.github.com/894540#file_intents.html
See: http://dev.twitter.com/pages/intents

However, I can't get this snippet work. I copied the snippet(JavaScript) code to an html file and open that in a browser. Nothing happened! What should I do to make it work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

栩栩如生 2024-11-23 18:37:56

我在纽约创业周末期间遇到了同样的问题。

他们提供的代码片段确实会根据需要打开 Twitter 弹出窗口,但 Twitter 弹出窗口将消息传递回网页的能力稍微复杂一些。您将需要了解他们的 widgets.js 代码如何工作并重现设置 RPC 框架所需的内容。我的短期解决方法是包含一个稍微修改(未混淆)的 widgets.js 版本,它不会用他们的按钮替换我的按钮。

如果你能等的话,我将在一两周内解决这个问题。

...或者你可以直接包含他们的 widgets.js :)

I had the same problem during NYC Startup Weekend.

The snippet they provide does open up the Twitter popup, as required, but the ability of the Twitter popup window to pass a message back to your web page is a little more complicated. You will need to understand how their widgets.js code works and reproduce what's necessary to set up the RPC framework. My short-term workaround was to include a slightly modified (un-obfuscated) version of widgets.js that would not replace my button with theirs.

I will be tackling this in a week or two, if you can wait.

... or you can just include their widgets.js directly :)

前事休说 2024-11-23 18:37:56

欢迎来到 Twitter API 文档的模糊世界。我认为你误解了,这与 API 页面上极其糟糕的措辞有很大关系:
嵌入该 javascript 代码允许您以“twitter 样式”弹出窗口打开 twitter web 意图页面,而无需依赖于 platform.twitter.com。它不允许允许您嵌入 Twitter 意图。

您可以通过添加该 javascript 然后将以下内容添加到您的页面来查看它的工作情况

New

单击“New”将在以下位置打开它:弹出窗口。删除 JavaScript,然后单击“新建”会将页面导航到推文框。

这让我非常沮丧,至少据我所知,它们不允许正确嵌入。我知道他们为什么采用这种方法,但仍然令人沮丧。

Welcome to the vague world of the Twitter API documentation.. I think you're misunderstanding, no small part to the incredibly poor wording on the API page:
Embedding that javascript code allows you to open the twitter web intent pages in a "twitter style" popup without requiring a dependency on platform.twitter.com. It does not allow you to embed a twitter intent.

You can see it at work by adding that javascript and then adding the following to your page
<p><a href="https://twitter.com/intent/tweet?">New</a></p>

Clicking "New" will open it in a popup. Remove the javascript, and clicking "New" will navigate the page away to the tweet box.

It's incredibly frustrating to me they don't, at least to my knowledge, allow for proper embedding. I know why they oped for this method, but it's frustrating none the less.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文