2011-03-11 49 views
0

我剛剛嘗試使用developers.facebook.com上給出的示例來打開請求表單並邀請朋友,因此我相應地更改了所有內容,但沒有任何反應,是否需要在某些情況下啓動它辦法?Facebook fb:請求表單不起作用

<?php 
$api_key = '...'; 
$secret = '...'; 
require_once 'facebook.php'; 

// Names and links 
$app_name = "..."; 
$app_url = "http://apps.facebook.com/.../"; // Assumes application is at http://apps.facebook.com/app-url/ 
$invite_href = "invite.php"; // Rename this as needed 

$facebook->require_frame(); 
$user2 = $facebook->require_login(); 

if(isset($_POST["ids"])) { 
    echo "<center>Thank you for inviting ".sizeof($_POST["ids"])." of your friends on <b><a href=\"http://apps.facebook.com/".$app_url."/\">".$app_name."</a></b>.<br><br>\n"; 
    echo "<h2><a href=\"http://apps.facebook.com/".$app_url."/\">Click here to return to ".$app_name."</a>.</h2></center>"; 
} else { 
    // Retrieve array of friends who've already authorized the app. 
    $fql = 'SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1='.$user2.') AND is_app_user = 1'; 
    $_friends = $facebook->api_client->fql_query($fql); 

    // Extract the user ID's returned in the FQL request into a new array. 
    $friends = array(); 
    if (is_array($_friends) && count($_friends)) { 
     foreach ($_friends as $friend) { 
      $friends[] = $friend['uid']; 
     } 
    } 

    // Convert the array of friends into a comma-delimeted string. 
    $friends = implode(',', $friends); 

    // Prepare the invitation text that all invited users will receive. 
    $content = 
     "<fb:name uid=\"".$user2."\" firstnameonly=\"true\" shownetwork=\"false\"/> has started using <a href=\"http://apps.facebook.com/".$app_url."/\">".$app_name."</a> and thought it's so cool even you should try it out!\n". 
     "<fb:req-choice url=\"".$facebook->get_add_url()."\" label=\"Put ".$app_name." on your profile\"/>"; 

?> 
<fb:request-form 
    action="<? echo $invite_href; ?>" 
    method="post" 
    type="<? echo $app_name; ?>" 
    content="<? echo htmlentities($content,ENT_COMPAT,'UTF-8'); ?>"> 

    <fb:multi-friend-selector 
     actiontext="Here are your friends who don't have <? echo $app_name; ?> yet. Invite whoever you want -it's free!" 
     exclude_ids="<? echo $friends; ?>" /> 
</fb:request-form> 
<?php 

} 

?> 

回答

1

招呼下面的代碼對我的作品

 
<fb:serverFbml width="760px"> 
    <script type="text/fbml"> 
    <fb:fbml> 
     <fb:request-form 
      action='http://apps.facebook.com/yoursite/' 
      method='POST' 
      type='photo fun' 
      content="Let's fun with facebook 
     <fb:req-choice url='http://www.yoursite.com' label='Register'/>" 
     <fb:multi-friend-selector actiontext="Select your friends."></fb:multi-friend-selector> 
    </fb:request-form> 
    </fb:fbml> 
    </script> 
</fb:serverFbml>