3

私はFacebook Recipe Boxチュートリアルを正常に実装しました。今私は静的なオープングラフのタグを使ってHTMLファイルを投稿するのではなく、これらのタグを動的に変更できる.phpファイルを投稿しています。FB.api関数を使用して.phpファイルをFacebookグラフにリンクできません

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"> 

    <head prefix="og: http://ogp.me/ns# carpenterben: http://ogp.me/ns/apps/carpenterben#"> 
    <meta property="fb:app_id" content="366730473342905" /> 
<meta property="og:type" content="carpenterben:nail" /> 
<meta property="og:title" content="Oreo Stuffed Cookies" /> 
<meta property="og:image" content="http://www.thepropagator.com/facebook/RecipeBox/cookie.jpg" /> 
<meta property="og:description" content="The Turducken of Cookies" /> 
<meta property="og:url" content="http://www.thepropagator.com/facebook/Carpenter/nail.php"> 

    <script type="text/javascript"> 
    function postCook() 
    { 
     FB.api('/me/carpenterben:hammer&nail=http://www.thepropagator.com/facebook/Carpenter/nail.php?name=great','post', function(response) { 
     if (!response || response.error) { 
      alert('Error occured'); 
      } else { 
      alert('Post was successful! Action ID: ' + response.id); 
      } 
    }); 
} 
    </script> 
</head> 

<body> 
    <div id="fb-root"></div> 
    <script src="http://connect.facebook.net/en_US/all.js"></script> 
    <script> 
    FB.init({ 
     appId:'366730473342905', cookie:true, 
       status:true, xfbml:true, oauth:true 
    }); 
    </script> 
    <fb:add-to-timeline></fb:add-to-timeline>> 
    <h3> 
     <font size="30" face="verdana" color="grey">Stuffed Cookies 
     </font> 
    </h3> 
    <p> 
     <img title="Oreo Stuffed Cookies" src="http://www.thepropagator.com/facebook/RecipeBox/cookie.jpg" width="550"/><br /> 
    </p> 

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

    <fb:activity actions="carpenterben:hammer"></fb:activity> 
</body> 

このリターン:

<?php 
function curPageURL() { 
$pageURL = 'http://'; 
if ($_SERVER["SERVER_PORT"] != "80") { 
    $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; 
} else { 
    $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; 
} 
    return $pageURL; 
    } 
    ?> 

    <html> 
    <head prefix="og: http://ogp.me/ns# wishlisteight: http://ogp.me/ns/fb/wishlisteight#"> 
      <meta property="fb:app_id"   content="366730473342905"> 
    <meta property="og:url"   content="<?php echo strip_tags(curPageURL());?>"> 
    <meta property="og:type"    content="carpenterben:nail"> 
    <meta property="og:title"    content="<?php echo strip_tags($_REQUEST['name']);?>"> 
     <meta property="og:image"    content="http://cdn2.digitaltrends.com/wp-content/uploads/2011/11/google_logo.jpg"> 
     <title>Product Name</title> 
    </head> 
    <body> 
    <div id="fb-root"></div> 
    <script src="http://connect.facebook.net/en_US/all.js"></script> 
    <script> 
    FB.init({ 
     appId:'366730473342905', cookie:true, 
     status:true, xfbml:true, oauth:true 
    }); 
    </script> 

    <fb:add-to-timeline></fb:add-to-timeline> 

    <h3> 
     <font size="30" face="verdana" color="grey"> 
      Stuffed Cookies 
     </font> 
    </h3> 
    <p> 
     <img title="Stuffed Cookies" 
         src="http://www.thepropagator.com/facebook/RecipeBox/cookie.jpg" 
         width="550"/><br /> 
    </p>  
</body> 
</html> 

私はポストを行うために使用しているコードは次のようである:私は投稿しようとしているPHPは以下の通りでありますエラーが発生しますが、2番目はHTMLへのファイル拡張子を変更しても問題ありません。誰でも説明できますか?

答えて

0

あなたは(エスケープ())あなたは、引数として渡しているURLをエンコードする必要があります。

/me/carpenterben:hammer&nail=http%3A//www.thepropagator.com/facebook/Carpenter/nail.php%3Fname%3Dgreat 

/me/carpenterben:hammer&nail=http://www.thepropagator.com/facebook/Carpenter/nail.php?name=great 

はちょうど

ような何かを行います
function postCook() 
{ 
    url = escape('http://www.thepropagator.com/facebook/Carpenter/nail.php?name=great') 
    FB.api('/me/carpenterben:hammer&nail='+url,'post', function(response) { 
    if (!response || response.error) { 
     alert('Error occured'); 
     } else { 
     alert('Post was successful! Action ID: ' + response.id); 
     } 
}); 
関連する問題