0

私はFacebookアプリの開発を始めており、Facebookのレシピボックスアプリチュートリアルに従っています。

https://developers.facebook.com/docs/opengraph/tutorial/

「アクションを公開」という見出しの下で、「クックボタンをクリックしてください」と表示されたままになっています。私のサイトでクリックすると、「エラーが発生しました」というエラーメッセージが表示された直後に表示されます。「アクションの横にある[コードを取得]リンクをクリックする」という部分を除いて、与えられた手順に従いました。これには、ターミナルにコピーして直接実行できるcurlコードスニペットが含まれています。私はカールコードをどうするかわかりませんでした...チュートリアルは実際にそれで何もするように言ったことはありません。

以下は私が今使っているコードです。私はrecipe.htmlファイルとobjectpage.htmlを持っています。これは、クックボタンをクリックしてエラーが発生する場所です。あなたが私に与えることができるどんな助けにも前もって感謝します!

レシピ.html:

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"
      xmlns:fb="https://www.facebook.com/2008/fbml"> 
<head>
  <title>OG Tutorial App</title>
</head>
<body>
  <div id="fb-root"></div>
  <script>
    window.fbAsyncInit = function() {
      FB.init({
        appId      : '266155930158877', // App ID
        status     : true, // check login status
        cookie     : true, // enable cookies to allow the server to access the session
        xfbml      : true  // parse XFBML
      });
    };

    // Load the SDK Asynchronously
    (function(d){
      var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
      js = d.createElement('script'); js.id = id; js.async = true;
      js.src = "//connect.facebook.net/en_US/all.js";
      d.getElementsByTagName('head')[0].appendChild(js);
    }(document));
  </script>

  <fb:login-button show-faces="true" width="200" max-rows="1" scope="publish_actions">
  </fb:login-button>

  <h3>Stuffed Cookies</h3>
  <p>
    <img title="Stuffed Cookies" 
         src="http://fbwerks.com:8000/zhen/cookie.jpg" 
         width="550"/>
  </p>
</body>
</html>

objectpage.html

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"
      xmlns:fb="https://www.facebook.com/2008/fbml"> 
<head prefix="og: http://ogp.me/ns# rk_recipebox: 
                  http://ogp.me/ns/apps/rk_recipebox#">
  <title>OG Tutorial App</title>
  <meta property="fb:app_id" content="266155930158877" /> 
  <meta property="og:type" content="rk_recipebox:recipe" /> 
  <meta property="og:title" content="Stuffed Cookies" /> 
  <meta property="og:image" content="http://fbwerks.com:8000/zhen/cookie.jpg" /> 
  <meta property="og:description" content="The Turducken of Cookies" /> 
  <meta property="og:url" content="http://fbwerks.com:8000/zhen/cookie.html">

  <script type="text/javascript">
  function postCook()
  {
      FB.api(
        '/me/rk_recipebox:cook',
        'post',
        { recipe: 'http://fbwerks.com:8000/zhen/cookie.html' },
        function(response) {
           if (!response || response.error) {
              alert('Error occured');
           } else {
              alert('Cook was successful! Action ID: ' + response.id);
           }
        });
  }
  </script>
</head>
<body>
  <div id="fb-root"></div>
  <script>
    window.fbAsyncInit = function() {
      FB.init({
        appId      : '266155930158877', // App ID
        status     : true, // check login status
        cookie     : true, // enable cookies to allow the server to access the session
        xfbml      : true  // parse XFBML
      });
    };

    // Load the SDK Asynchronously
    (function(d){
      var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
      js = d.createElement('script'); js.id = id; js.async = true;
      js.src = "//connect.facebook.net/en_US/all.js";
      d.getElementsByTagName('head')[0].appendChild(js);
    }(document));
  </script>

  <h3>Stuffed Cookies</h3>
  <p>
    <img title="Stuffed Cookies" 
         src="http://fbwerks.com:8000/zhen/cookie.jpg" 
         width="550"/>
  </p>

  <br>
  <form>
    <input type="button" value="Cook" onclick="postCook()" />
  </form>
</body>
</html>

ページはここにあります:

http://glutendatabase.com/objectpage.html

4

1 に答える 1

1

ファイルで、関数をこれobjectpage.htmlに置き換えます。postCook()これにより、少なくともエラーが何であるかがわかります。

私の推測では、あなたはまだあなたのウェブページのURLではなく、与えられた例のURLをPOSTしようとしていると思います(以下の6行目を参照)。サーバーがLOCALHOSTの場合、それもエラーをスローします。名前付きサーバー上にいる必要があります。

function postCook()
{
  FB.api(
    '/me/rk_recipebox:cook',
    'post',
    { recipe: 'http://YOURSERVER/objectpage.html' },
    function(response) {
       if (!response) {
          alert('Error occurred : No Response');
       } else if (response.error) {
          alert('Error occurred : ' + response.error);
       } else {
          alert('Cook was successful! Action ID: ' + response.id);
       }
    });
}
于 2012-06-14T16:53:43.240 に答える