没有登录两次就没有发布Facebook开放图形故事

时间:2014-08-02 18:09:48

标签: facebook facebook-graph-api facebook-opengraph

我正在尝试发布一个开放的图形故事。我面临的问题是用户必须登录两次才能发布故事。我已经使用开发人员的帐户和测试用户的帐户进行了尝试。当我点击登录按钮时,我登录但没有发布故事然后我再次点击登录按钮然后我得到一个肯定的回复和一个故事发布,可以在我的活动日志中看到。我真的不知道我做错了什么,我在搜索之前已经搜索了很多。在这方面的任何帮助将受到高度赞赏。

链接到我的测试网站: - www.funtemple.net

我的HTML文件看起来像这样

<!DOCTYPE html>
<html>
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# funtemple: http://ogp.me/ns/fb/funtemple#">
  <meta property="fb:app_id" content="Hidden" /> 
  <meta property="og:type"   content="funtemple:board" /> 
  <meta property="og:url"    content="http://funtemple.net/index.html" /> 
  <meta property="og:title"  content="Sample Board" /> 
  <meta property="og:image"  content="https://fbstatic-a.akamaihd.net/images/devsite/attachment_blank.png" /> 

<link rel="stylesheet" href="hello.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<title>Open Graph Getting Started App - og.likes</title>
<style type="text/css">
div { padding: 10px; }
</style>
<meta charset="UTF-8">
</head>
<body>
 <script>
      window.fbAsyncInit = function() {
        FB.init({
          appId      : 'Hidden',
          xfbml      : true,
          version    : 'v2.0'
        });
      };

      (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>

<header>
        Welcome to the message board app
    </header>
        <h1 class ="headingName">Hello </h1>

        <button class = 'loginButton'> Press me to Login </button>

        <br>
        <br>
        <br>

        <div class="message">
        <h5>Warning</h5>
        </div>

        <br>
        <br>
        <br>
        <br>

        <div class="message2">
        <h5>Important Info</h5>
        </div>

    <footer>
    </footer>

<script src="hello.js"> </script>

</body>
</html>

我的JaveScript文件看起来像

$('.loginButton').click(function(){

 // FACEBOOK LOGIN
   FB.login(function(response) {


 // GETTING FACEBOOK DATA

      FB.api('/me', function(response) {

        // stuff you want to happen after getting data goes here
     // alert(response.name);
       //console.log(response);

      $(".headingName").append(response.name);

      }); //FB.api

      // END - FACEBOOK DATA

 },{scope: 'publish_actions'}); //FB.login

   // END - FACEBOOK LOGIN

}); //click

$('.message').click(function(){

 FB.getLoginStatus(

 function(response){
 //alert(response.status);
if(response.status=="connected")
{

FB.api(
  'me/funtemple:view',
  'post',
  {
    board: "http://funtemple.net/index.html"
  },
  function(response) {

  if(!response || response.error){
  alert(JSON.stringify(response.error));
  alert('Error Occurred' + response.responseText + " " + response.error.responseText);

  } 
  else{

  alert('Action was successful! Action ID:' + response.id);

}

  }
);



 window.open('http://funtemple.net/warning.html',' mywindow ',' width=400 ,height=200' );
}

else{
 alert("Please Login to use the message board");

}

}
);

}); //click

$('.message2').click(function(){

 alert('Hello2');

}); //click

0 个答案:

没有答案