1

我剛在Facebook上創建了一個應用程序來使用Audience Network。我想通過我的網站獲利。我將代碼放在我的網站上,就像它出現在github文檔中的橫幅廣告一樣。Facebook Javascript SDK Audience網絡錯誤1003

我包含在頁面的SDK,正是因爲它出現在這個文檔(換成我的APP ID) https://developers.facebook.com/docs/javascript/quickstart

而且我使用的廣告展示位置從Facebook的GitHub庫正是採取的代碼。

當我加載頁面時,我在控制檯中得到一個錯誤: "Audience Network error (1003) SDK version not supported".沒有廣告顯示。

做了一個小測試頁面,讓你們可以看到我在說什麼。通知等,並共享按鈕的工作原理(這意味着SDK正常工作,如果我沒有記錯?) https://somiibo.com/app/ads/sidebar/ad1.html

<script> 
    window.fbAsyncInit = function() { 
    FB.init({ 
     appId  : '1490948314307293', 
     xfbml  : true, 
     version : 'v2.10' 
    }); 
    FB.AppEvents.logPageView(); 
    }; 
    (function(d, s, id){ 
    var js, fjs = d.getElementsByTagName(s)[0]; 
    if (d.getElementById(id)) {return;} 
    js = d.createElement(s); js.id = id; 
    js.src = "//connect.facebook.net/en_US/sdk.js"; 
    fjs.parentNode.insertBefore(js, fjs); 
    }(document, 'script', 'facebook-jssdk')); 
</script> 
    <div 
    class="fb-like" 
    data-share="true" 
    data-width="450" 
    data-show-faces="true"> 
</div> 
    <h3>Facebook Audience Network for Mobile Web</h3> 
    <hr/> 
    <h3>Banner Demo (300 x 250)</h3> 
    <br/> 
    <div style="display:none; position: relative;"> 
    <iframe style="display:none;"></iframe> 
    <script type="text/javascript"> 
     var data = { 
     placementid: '1490948314307293_1490949464307178', 
     format: '300x250', 
     testmode: false, 
     onAdLoaded: function(element) { 
      console.log('Audience Network ad loaded'); 
      element.style.display = 'block'; 
     }, 
     onAdError: function(errorCode, errorMessage) { 
      console.log('Audience Network error (' + errorCode + ') ' + errorMessage); 
     } 
     }; 
     (function(w,l,d,t){var a=t();var b=d.currentScript||(function(){var c=d.getElementsByTagName('script');return c[c.length-1];})();var e=b.parentElement;e.dataset.placementid=data.placementid;var f=function(v){try{return v.document.referrer;}catch(e){}return'';};var g=function(h){var i=h.indexOf('/',h.indexOf('://')+3);if(i===-1){return h;}return h.substring(0,i);};var j=[l.href];var k=false;var m=false;if(w!==w.parent){var n;var o=w;while(o!==n){var h;try{m=m||(o.$sf&&o.$sf.ext);h=o.location.href;}catch(e){k=true;}j.push(h||f(n));n=o;o=o.parent;}}var p=l.ancestorOrigins;if(p){if(p.length>0){data.domain=p[p.length-1];}else{data.domain=g(j[j.length-1]);}}data.url=j[j.length-1];data.channel=g(j[0]);data.width=screen.width;data.height=screen.height;data.pixelratio=w.devicePixelRatio;data.placementindex=w.ADNW&&w.ADNW.Ads?w.ADNW.Ads.length:0;data.crossdomain=k;data.safeframe=!!m;var q={};q.iframe=e.firstElementChild;var r='https://www.facebook.com/audiencenetwork/web/?sdk=5.3';for(var s in data){q[s]=data[s];if(typeof(data[s])!=='function'){r+='&'+s+'='+encodeURIComponent(data[s]);}}q.iframe.src=r;q.tagJsInitTime=a;q.rootElement=e;q.events=[];w.addEventListener('message',function(u){if(u.source!==q.iframe.contentWindow){return;}u.data.receivedTimestamp=t();if(this.sdkEventHandler){this.sdkEventHandler(u.data);}else{this.events.push(u.data);}}.bind(q),false);q.tagJsIframeAppendedTime=t();w.ADNW=w.ADNW||{};w.ADNW.Ads=w.ADNW.Ads||[];w.ADNW.Ads.push(q);w.ADNW.init&&w.ADNW.init(q);})(window,location,document,Date.now||function(){return+new Date;}); 
    </script> 
    <script type="text/javascript" src="https://connect.facebook.net/en_US/fbadnw.js" async></script> 
    </div> 
    <hr/> 
    <h3>Banner Demo (320 x 50)</h3> 
    <br/> 
    <div style="display:none; position: relative;"> 
    <iframe style="display:none;"></iframe> 
    <script type="text/javascript"> 
     var data = { 
     placementid: '1490948314307293_1490949464307178', 
     format: '320x50', 
     testmode: false, 
     onAdLoaded: function(element) { 
      console.log('Audience Network ad loaded'); 
      element.style.display = 'block'; 
     }, 
     onAdError: function(errorCode, errorMessage) { 
      console.log('Audience Network error (' + errorCode + ') ' + errorMessage); 
     } 
     }; 
     (function(w,l,d,t){var a=t();var b=d.currentScript||(function(){var c=d.getElementsByTagName('script');return c[c.length-1];})();var e=b.parentElement;e.dataset.placementid=data.placementid;var f=function(v){try{return v.document.referrer;}catch(e){}return'';};var g=function(h){var i=h.indexOf('/',h.indexOf('://')+3);if(i===-1){return h;}return h.substring(0,i);};var j=[l.href];var k=false;var m=false;if(w!==w.parent){var n;var o=w;while(o!==n){var h;try{m=m||(o.$sf&&o.$sf.ext);h=o.location.href;}catch(e){k=true;}j.push(h||f(n));n=o;o=o.parent;}}var p=l.ancestorOrigins;if(p){if(p.length>0){data.domain=p[p.length-1];}else{data.domain=g(j[j.length-1]);}}data.url=j[j.length-1];data.channel=g(j[0]);data.width=screen.width;data.height=screen.height;data.pixelratio=w.devicePixelRatio;data.placementindex=w.ADNW&&w.ADNW.Ads?w.ADNW.Ads.length:0;data.crossdomain=k;data.safeframe=!!m;var q={};q.iframe=e.firstElementChild;var r='https://www.facebook.com/audiencenetwork/web/?sdk=5.3';for(var s in data){q[s]=data[s];if(typeof(data[s])!=='function'){r+='&'+s+'='+encodeURIComponent(data[s]);}}q.iframe.src=r;q.tagJsInitTime=a;q.rootElement=e;q.events=[];w.addEventListener('message',function(u){if(u.source!==q.iframe.contentWindow){return;}u.data.receivedTimestamp=t();if(this.sdkEventHandler){this.sdkEventHandler(u.data);}else{this.events.push(u.data);}}.bind(q),false);q.tagJsIframeAppendedTime=t();w.ADNW=w.ADNW||{};w.ADNW.Ads=w.ADNW.Ads||[];w.ADNW.Ads.push(q);w.ADNW.init&&w.ADNW.init(q);})(window,location,document,Date.now||function(){return+new Date;}); 
    </script> 
    <script type="text/javascript" src="https://connect.facebook.net/en_US/fbadnw.js" async></script> 
    </div> 
+1

嗨伊恩,歡迎來到SO。請儘可能包含代碼片段。如果你不依賴我們來追逐你的鏈接,你會得到更多的迴應。但鏈接到演示網站的+1。 – Chiperific

回答

0

可以更換SDK https://www.facebook.com/audiencenetwork/web/?sdk=5.3https://www.facebook.com/audiencenetwork/web/?sdk=5.5 我希望我可以幫助你。