提交时打开图形错误 - 发布流故事

时间:2012-10-08 14:39:46

标签: facebook facebook-graph-api authentication stream publish

你能发现我的错误吗?

我真的很难获得批准的开放式图表操作。我希望人们共享(操作)照片(对象)并请求用户消息和显式共享功能。我从Facebook回来的最新评论是:

  

由于您的应用中存在错误,我们无法测试此操作。   请通过测试确保您的操作正常运行   Auth对话预览用户并重新提交。

不是很有用!

我已经使用Auth Dialog预览用户测试了我的操作,它运行正常。我还用对象调试器测试了我的页面,它返回了响应代码200 - 这显然意味着一切正常(这是正确的吗?)。

以下是我在测试页面上使用的代码,并希望有人能够指出我的错误在哪里,因为我看不到它:

<head>
meta tags here

<script type="text/javascript">
  function Share()
  {
      FB.api(
        '/me/NAMESPACE:share&photo=TEST PAGE URL&message=Cool photos&fb:explicitly_shared=true&access_token=ACCESS TOKEN','POST',  function(response) {
            if (!response || response.error) {
                alert('Error occured');
              } else {
                alert('Post was successful! Action ID: ' + response.id);
              }
        });
    }
  </script>


<script type="text/javascript">
window.fbAsyncInit = function() {
FB.Canvas.setAutoGrow();
}
// Do things that will sometimes call sizeChangeCallback()
function sizeChangeCallback() {
FB.Canvas.setSize({ width: 810, height: 1180 });
}
</script>
</head>
<body>
<div id="fb-root"></div>
    <script>
      // Load the SDK Asynchronously
      (function(d){
         var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
         if (d.getElementById(id)) {return;}
         js = d.createElement('script'); js.id = id; js.async = true;
         js.src = "//connect.facebook.net/en_US/all.js";
         ref.parentNode.insertBefore(js, ref);
       }(document));

      // Init the SDK upon load
      window.fbAsyncInit = function() {
        FB.init({
          appId      : 'APP ID', // App ID
          channelUrl : '//CHANNEL FILE URL', // Path to your Channel File
          status     : true, // check login status
          cookie     : true, // enable cookies to allow the server to access the session
          xfbml      : true,  // parse XFBML
          oauth      :true
        });

        // listen for and handle auth.statusChange events
        FB.Event.subscribe('auth.statusChange', function(response) {
          if (response.authResponse) {
            // user has auth'd your app and is logged into Facebook
            FB.api('/me', function(me){
              if (me.name) {
                document.getElementById('auth-displayname').innerHTML = me.name;
              }
            })
            document.getElementById('auth-loggedout').style.display = 'none';
            document.getElementById('auth-loggedin').style.display = 'block';
          } else {
            // user has not auth'd your app, or is not logged into Facebook
            document.getElementById('auth-loggedout').style.display = 'block';
            document.getElementById('auth-loggedin').style.display = 'none';
          }
        });

        // respond to clicks on the login and logout links
        document.getElementById('auth-loginlink').addEventListener('click', function(){
          FB.login();
        });
        document.getElementById('auth-logoutlink').addEventListener('click', function(){
          FB.logout();
        }); 
      } 

      function loginUser() {    
     FB.login(function(response) { }, {scope:'publish_actions, email'});     
     }
    </script>

 <div id="auth-status">
        <div id="auth-loggedout">
          <a href="#" id="auth-loginlink"><img src="login_btn.png"></a>
        </div>
        <div id="auth-loggedin" style="display:none">

      </div>
    </div>

<form>
    <input class="shr-btn" type="button" value="" onClick="Share()" />
  </form>

</body>

感谢任何帮助。

非常感谢

d


Aaarrggh。我现在收到了Facebook的回复:

  

您的代码目前已配置为发布流故事。你必须   更改您的代码,以便在测试用户触发操作时   产生一个开放的图形故事。请进行适当的更改   重新提交。

有人可以让我知道我做错了什么吗?我认为代码的设置是为了发布一个开放的图形故事 - 但显然现在。

如果有人能指出我做错了什么,我会永远感激。

非常感谢。

d

2 个答案:

答案 0 :(得分:0)

这似乎与你如何传递这一行中的其他参数有关:

'/me/NAMESPACE:share&photo=TEST PAGE URL&message=Cool photos&
fb:explicitly_shared=true&access_token=ACCESS TOKEN','POST',  function(response)

你真的想做更多的事情:

FB.api('/me/NAMESPACE:share', 'post', 
{ photo : 'TEST_PAGEURL', message : 'Cool photos' }, function(response));

这里重要的是将自定义JSON内容作为函数的第三个参数包含在内。似乎URL参数方法可能会触发那种消息,因为它是一个较旧的实现。

答案 1 :(得分:-1)

不,这不是因为您使用动词“分享”创建故事。我刚刚获得Facebook批准的故事,我使用动词“分享”。我的故事早先被拒绝了,原因和你的一样。

基本上,当您使用开放图形故事时,您无法在相册或任何其他类型的帖子上发布内容。例如,不允许以下内容:

                $data = $facebook->api('/me/photos', 'post', $args);//disallowed                
                $facebook->api(
                  'me/invig-test:share',
                  'POST',
                  array(
                        'app_id' => $configParam['appId'],
                        'type' => "test:photo",
                        'photo' => "http://samples.ogp.me/574859819237737",                   
                        'title' => "a photo",
                        'image[0][url]'=>"http://www.testapp.com/".$imgFile,
                        'image[0][user_generated]'=>'true',
                        'message' => $comments,                   
                        'fb:explicitly_shared'=>true,
                    )
                  );

而只做“分享”:

                $facebook->api(
                  'me/invig-test:share',
                  'POST',
                  array(
                        'app_id' => $configParam['appId'],
                        'type' => "test:photo",
                        'photo' => "http://samples.ogp.me/574859819237737",                   
                        'title' => "a photo",
                        'image[0][url]'=>"http://www.testapp.com/".$imgFile,
                        'image[0][user_generated]'=>'true',
                        'message' => $comments,                   
                        'fb:explicitly_shared'=>true,
                    )
                  );