2013-07-25 3 views
0

Facebook PHP 앱을 만들었으며 요청 대화 상자를 만들려고했습니다. SDK를 사용했지만 친구 초대를 클릭하면 나타나지 않습니다. Facebook 앱 요청 대화 상자가 나타나지 않습니다.

코드입니다 : 그 후

<?php 
// PATH TO THE FB-PHP-SDK 
require_once 'src/facebook.php'; 
$facebook = new Facebook(array(
    'appId' => '475970839112689', 
    'secret' => '4ae240ac95f687af581ff1596d06121d' 
)); 

$user = $facebook->getUser(); 
$loginUrl = $facebook->getLoginUrl(); 

if (empty($user)) { 
    echo("<script> top.location.href='" . $loginUrl . "'</script>"); 
    exit(); 
} 
?> 
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> 
etc... 

, 나는 대화의 JS로드 및 링크 생성 : 그래서

<div id="fb-root"></div> 

<script> 
window.fbAsyncInit = function() { 
    FB.init({ 
     appId: '475970839161689', 
     status: true, 
     cookie: true, 
     oauth: true 
    }); 
}; 

$('a').click(sendRequest); 
function sendRequest() { 
    FB.ui({ 
     method: 'apprequests', 
     message: 'Vino si soializeaza si tu pe Social Chat!', 
     title: 'Trimite prietenilor tai o invitatie', 
    }, 
    function (response) { 
     if (response.request && response.to) { 
      var request_ids = []; 
      for(i=0; i<response.to.length; i++) { 
       var temp = response.request + '_' + response.to[i]; 
       request_ids.push(temp); 
      } 
      var requests = request_ids.join(','); 
      $.post('handle_requests.php',{uid: <?php echo $user; ?>, request_ids: requests},function(resp) { 
       // callback after storing the requests 
      }); 
     } else { 
      alert('canceled'); 
     } 
    }); 
    return false; 
} 

    // 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/ro_RO/all.js"; 
d.getElementsByTagName('head')[0].appendChild(js); 
}(document)); 
</script> 

<a href="#">Invite friends</a> 

, 나는 친구가 그것을 초대 링크를 클릭 아무것도하지 않는다.

답변

0

그냥 같이 준비 기능에 클릭 기능을 포장 :

$(document).ready(function() { 
    $('a').click(sendRequest); 
}); 
+0

가 대단히 감사합니다. 이것이 문제였습니다. – Mihai

관련 문제