【问题标题】:Open Graph error on submission - publishing a stream story提交时打开图错误 - 发布流故事
【发布时间】:2012-10-08 14:39:45
【问题描述】:

你能看出我的错误吗?

我真的很难让开放图形操作获得批准。我希望人们分享(操作)照片(对象)并请求用户消息和明确共享的功能。我从 Facebook 收到的最新评论是:

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

不是很有帮助!

我已经使用 Auth Dialog Preview User 测试了我的操作,并且效果很好。我还使用返回响应代码 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


啊啊啊。我现在收到了来自 Facebook 的回复:

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

有人可以告诉我我做错了什么吗?我以为代码是为了发布一个开放的图表故事而设置的——但显然是现在。

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

非常感谢。

D

【问题讨论】:

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


    【解决方案1】:

    这似乎与您在这一行中传递附加参数的方式有关:

    '/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 参数方法可能会触发这种消息,因为它是一个较旧的实现。

    【讨论】:

    • 感谢Critical Sass 的回复。问题原来是我试图将“共享”一词用作开放图形操作。我认为分享是一个与流故事相关的术语,而不是开放图。我不知道他们为什么不能直接指出这一点!
    • 据我所见,分享实际上是一个 default Open Graph 操作链接,以及 likecomment - 这可能就是原因!
    【解决方案2】:

    不,这不是因为您正在使用动词“分享”来创建故事。我刚刚获得了 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,
                        )
                      );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-08-17
      • 2016-01-27
      • 2023-03-12
      • 2015-04-25
      • 1970-01-01
      • 2013-07-03
      • 2023-04-03
      相关资源
      最近更新 更多