如何在我的网站上调试Facebook JavaScript api错误?

时间:2011-02-17 23:03:51

标签: javascript debugging facebook

我正在添加一个指向我网站的链接,该链接将允许用户在Facebook墙上分享页面上发生的事情。

为此,我正在使用Facebook Javascript API。我脑子里有以下代码。

<script src="http://static.ak.fbcdn.net/connect/en_US/core.debug.js" type="text/javascript"></script>

稍后在正文中,我调用代码发布到用户的流。

window.fbAsyncInit = function() { 
        FB.init({
            appId: "XXXXXXXXXXX",
            status: true, 
            cookie: true, 
            xfbml: true,
            level  : "debug"
        }); 
    }; 
    streamPublish = function(){
        var session = Session.get('eres_user_data');
        var argumentsURL = "";
        var confirmFacebookTitle = "";
        var confirmFacebookMessage = "";

        if (session.promoCode != null && session.promoCode != ""){
            argumentsURL = "https://www.totalrewards.com/hotel-reservations/?propcode="+session.propCode+"&promotioncode="+session.promoCode+"view=ratecal&social="+session.propCode+"_tw_eResShare";
            confirmFacebookTitle = "It's time to play at "+session.propName+"!";
            confirmFacebookMessage = "I just saved "+ confirmationMod_session.savings+" by using the "+confirmationMod_session.promoName+" online at "+confirmationMod_session.propName+"!";
        }
        else if (session.showHotDeals == "Y"){
            argumentsURL = "https://www.totalrewards.com/hotel-reservations/?propcode="+session.propCode+"view=ratecal&showhotdeals=y&social="+session.propCode+"_tw_eResShare";
            confirmFacebookTitle = "I booked a smoking hot deal at "+session.propName+"!";
            confirmFacebookMessage = "I just made a reservation at "+session.propName+" using the 'Hot Deals Calendar'. Guaranteed lowest rates, and so easy to book. Wish me luck!";
        }
        else if (session.packageCode != null && session.packageCode != ""){
            argumentsURL = "https://www.totalrewards.com/hotel-reservations/?propcode="+session.propCode+"&packagecode="+session.packagecode+"view=ratecal&social="+session.propCode+"_tw_eResShare";
            confirmFacebookTitle = "I booked a "+session.packageName+" package deal at "+session.propName+"!";
            confirmFacebookMessage = "I just made a reservation at "+session.propName+" online. Guaranteed lowest rates, and so easy to book. Wish me luck!";
        }
        else{
            argumentsURL = "https://www.totalrewards.com/hotel-reservations/?propcode="+session.propCode+"&view=ratecal&social="+session.propCode+"_tw_eResShare";
            confirmFacebookTitle = "It's time to play at "+session.propName+"!";
            confirmFacebookMessage = "I just made a reservation at "+session.propName+" online. Guaranteed lowest rates, and so easy to book. Wish me luck!";
        }
        FB.ui(
           {
             method: 'stream.publish',
             display:'dialog',
             message: 'test',
             attachment: {
               name: confirmFacebookTitle,
               caption: '',
               description: confirmFacebookMessage,
               'media': [{ 
                    'type': 'image',
                    'src': 'http://www.caesars.com/images/casinos/'+session.propCode+'MET_alt.png',
                    'href': argumentsURL
                    }],
               href: argumentsURL
             },
             action_links: [
               { text: 'Find Rates', href: argumentsURL}
             ],
             user_message_prompt: 'Tell your friends about your getaway.'
           },
           function(response) {
           }
         );

    } 

当用户点击“分享”链接时,会出现一个Facebook窗口,但只有文本错误。 “发生了一个错误。请稍后重试。”就是所有的东西都显示出来了 https://www.facebook.com/dialog/stream.publish?action_links=[{%22text%22:%22Find%20Rates%22,%22href%22:%22https://www.totalrewards.com/hotel-reservations/%3Fpropcode%3DMET%26view%3Dratecal%26social%3DMET_tw_eResShare%22}]&attachment={%22name%22:%22It's%20time%20to%20play%20at%20Harrah's%20Metropolis!%22,%22caption%22:%22%22,%22description%22:%22I%20just%20made%20a%20reservation%20at%20Harrah's%20Metropolis%20online.%20Guaranteed%20lowest%20rates,%20and%20so%20easy%20to%20book.%20Wish%20me%20luck!%22,%22media%22:[{%22type%22:%22image%22,%22src%22:%22http://www.caesars.com/images/casinos/METMET_alt.png%22,%22href%22:%22https://www.totalrewards.com/hotel-reservations/%3Fpropcode%3DMET%26view%3Dratecal%26social%3DMET_tw_eResShare%22}],%22href%22:%22https://www.totalrewards.com/hotel-reservations/%3Fpropcode%3DMET%26view%3Dratecal%26social%3DMET_tw_eResShare%22}&display=popup&locale=en_US&message=test&next=http://static.ak.fbcdn.net/connect/xd_proxy.php%23cb%3Df2b8d16234%26relation%3Dopener%26frame%3Df2f644938%26result%3D%2522xxRESULTTOKENxx%2522&sdk=joey&user_message_prompt=Tell%20your%20friends%20about%20your%20getaway

我如何解决此问题?我没有看到任何javascript错误,我不知道哪里会出现任何错误。任何帮助将不胜感激我的过去这个问题。 “发生错误,请稍后再试”根本没有帮助我。

1 个答案:

答案 0 :(得分:0)

看来这个javascript lib已经过时了:)是的,因为这个问题只是庆祝他的第一个生日。 stream.publish很快就会消失。