Twitter Web Intents API Documentationを見ると、ページの下部に、APIが自動的にリンクを処理する方法を示す、わかりにくいソースコードへのリンクがあります。
クリックイベントハンドラをDOMに接続するだけで、クリックされたリンクがWeb Intents URLをポイントしているかどうかが確認されます。 ActionScriptからウィンドウを開くと、DOMをバイパスしているので、コードは起動しません。
通常は、Web Intents APIで公開されているメソッドを呼び出すためにExternalInterfaceを使用します。しかし、Twitterの賢い人形は、DOMを汚染するのを避けるために、API全体を匿名の閉鎖で作成しています - JavaScriptが大好きです)
私は個人的にTwitter Web Intents APIの独自のバージョンを作成し、私のFlashアプリケーションが置いているHTMLページにそれを含めてください。例えば:
// Create a global object which we can attach methods to.
var TwitterAPI = {};
// The methods themselves are created in a closure to avoid polluting the global
// namespace with temporary variables.
(function() {
// The base URL of the Twitter API.
TwitterAPI.baseURL = "https://twitter.com/intent/";
// Opens a pop-up window and prompts the user to retweet the Tweet linked to
// the supplied tweet_id.
TwitterAPI.retweet = function(tweet_id) {
var url = TwitterAPI.baseURL + "retweet?tweet_id=" + tweet_id;
openWindow(url);
}
function openWindow(url) {
var windowOptions = "scrollbars=yes,resizable=yes,toolbar=no,location=yes";
var width = 550;
var height = 420;
// Center the popup window.
var left = Math.round((screen.width/2) - (width/2));
var top = 0;
if (screen.height > height) {
top = Math.round((screen.height/2) - (height/2));
}
window.open(url, 'intent', windowOptions + ",width=" + width +
",height=" + height + ",left=" + left + ",top=" + top);
}
}());
あなたは、あなたが以前に示唆したように、ExternalInterfaceの呼び出しによって、あなたのActionScriptプロジェクトからこれを呼び出すことができます。私は確かに私はそれを行う必要はありません期待していた
ExternalInterface.call("TwitterAPI.retweet", "35782000644194304");
が、私あなたが正しいと思います。また、Twitterで連絡先に電子メールを送って、これに関する意見があるかどうかを確認します。あなたの助けをありがとう! –
質問をしてこのスレッドに飛び乗っていただきありがとうございました。ルーチンは正常に動作しますが、私が把握できなかったことは、ツイートの投稿後にTwitterのコールバックイベントを発生させる方法です。通常、次のようにコールバックが設定されます。twttr.events.bind( 'retweet'、function(event){alert( 'retweet posted');});あなたが投稿したTwitterAPIを使って作業するにはどうしたらいいですか?親切にありがとう! – Victor