如何检测“共享”使用动作脚本?

发布于 2024-12-11 12:58:04 字数 960 浏览 1 评论 0原文

我们都知道可以为 Facebook 制作一个共享按钮,允许用户共享任何项目。但是当我们被引导到该页面时,用户有两个选择。按“取消”按钮,这当然会关闭窗口,或者按“共享”按钮,然后将项目添加到人员墙上。

我想做的是确定是否已按下该共享按钮。因为当他们按下它时,我希望我的 swf 追踪出一条消息,说“感谢分享我的项目”

,虽然我可以将它们重定向到该页面,但我无法知道他们是否共享它。我的想法是使用 Enter_frame 事件并尝试查看是否有任何数据通过 php 发送。因为这就是按钮按下时会执行的操作。但我没有运气让它发挥作用。

这是到目前为止的代码。这是一个教程,因为重点是我的问题:

import flash.net.navigateToURL; import flash.net.URLVariables; import flash.net.URLRequest; import flash.net.URLRequestMethod; share_btn.addEventListener(MouseEvent.CLICK, shareClickHandler); function shareClickHandler(evt:MouseEvent):void {     var varsShare:URLVariables = new URLVariables();     varsShare.u = 'http://domain.com/pageN.html';     varsShare.t = 'Title Page';     var urlFacebookShare:URLRequest = new URLRequest('http://www.facebook.com/sharer.php');     urlFacebookShare.data = varsShare;     urlFacebookShare.method = URLRequestMethod.GET;     navigateToURL(urlFacebookShare, '_blank'); }

we all know its possible to make a share button for face book which allows users to share whatever item. but when we are directed to that page the user has two options. press the "cancel" button which of course closes the window, or to press the "share" button which then adds the item to the persons wall.

what i'm trying to do is determine if that share button has been pressed. see because when they press it i want my swf to trace out a message saying "thanks for sharing my item"

and while i can redirect them to the page i have no way of knowing if they shared it or not. my idea was to use an enter_frame event and try and see if any data was being sent via php. because thats what the button would be doing when pressed. but i haven't had any luck making that work.

here is the code so far. its a tutorial as the focus is at my problem:

import flash.net.navigateToURL; import flash.net.URLVariables; import flash.net.URLRequest; import flash.net.URLRequestMethod; share_btn.addEventListener(MouseEvent.CLICK, shareClickHandler); function shareClickHandler(evt:MouseEvent):void {     var varsShare:URLVariables = new URLVariables();     varsShare.u = 'http://domain.com/pageN.html';     varsShare.t = 'Title Page';     var urlFacebookShare:URLRequest = new URLRequest('http://www.facebook.com/sharer.php');     urlFacebookShare.data = varsShare;     urlFacebookShare.method = URLRequestMethod.GET;     navigateToURL(urlFacebookShare, '_blank'); }

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

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

发布评论

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

评论(1

谁把谁当真 2024-12-18 12:58:04

我使用静态类进行共享。
看看这个:

package shvyrev.com.utils 
{
    import flash.events.EventDispatcher;
    import flash.external.ExternalInterface;

    public class ShareUtil 
    {
        static private var url:String;
        static private var feedFunction:Function;

        static public function shareFacebookExt(appID:String, title:String, titleLink:String, caption:String, description:String, imageSource:String, redirectUrl:String = '', feedBackFunction:Function = null):void
        {
            url = 'http://www.facebook.com/dialog/feed?app_id=' + appID + '&picture=' + imageSource + '&name=' + escape(title) + '&link=' + escape(titleLink) + '&caption=' + escape(caption) + '&description=' + escape(description) + '&display=' + 'popup' + '&redirect_uri=' + redirectUrl;

            feedFunction = feedBackFunction;

            try 
            {
                if (redirectUrl !== '' && feedFunction !== null) ExternalInterface.call('confirmPost', handler_confirm);
                ExternalInterface.call("window.open", url , "win", "height=400,width=580,toolbar=no,scrollbars=no");
            }catch (err:Error)
            {
                if (feedFunction !== null) feedFunction.call(null, 'facebook share unaviable');
            }
        }

        static private function handler_confirm():void 
        {
            feedFunction.call(null, 'handler_confirm')
        }
    }
}

I use static class for share.
Look at this:

package shvyrev.com.utils 
{
    import flash.events.EventDispatcher;
    import flash.external.ExternalInterface;

    public class ShareUtil 
    {
        static private var url:String;
        static private var feedFunction:Function;

        static public function shareFacebookExt(appID:String, title:String, titleLink:String, caption:String, description:String, imageSource:String, redirectUrl:String = '', feedBackFunction:Function = null):void
        {
            url = 'http://www.facebook.com/dialog/feed?app_id=' + appID + '&picture=' + imageSource + '&name=' + escape(title) + '&link=' + escape(titleLink) + '&caption=' + escape(caption) + '&description=' + escape(description) + '&display=' + 'popup' + '&redirect_uri=' + redirectUrl;

            feedFunction = feedBackFunction;

            try 
            {
                if (redirectUrl !== '' && feedFunction !== null) ExternalInterface.call('confirmPost', handler_confirm);
                ExternalInterface.call("window.open", url , "win", "height=400,width=580,toolbar=no,scrollbars=no");
            }catch (err:Error)
            {
                if (feedFunction !== null) feedFunction.call(null, 'facebook share unaviable');
            }
        }

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