我在这里订阅了https://developers.facebook.com/apps/301135526661971/realtime?save=1到实时更新成功“测试”没问题。我的“字段”设置为“online_presence”、“朋友”、“状态”、“状态”,但 Facebook 从不更新我!?这是我的回调.php:
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<script type="text/javascript" src="jquery-1-7-2.js"></script>
<style>
body{font-style:normal;font-size;12px/1.1em;font-family:"lucida grande",tahoma,verdana,arial,sans-serif;line-height:1.4em;font-size:62.5%;background-color:#FFFFFF;}
A.update:link {text-decoration:none;color:#DEE3ED;font-weight:bold;}
A.update:visited {text-decoration:none;color:#DEE3ED;font-weight:bold;}
A.update:active {text-decoration:none;color:#DEE3ED;font-weight:bold;}
A.update:hover {text-decoration:none;color:#FFF;font-weight:bold;}
.Bf{width:183px;height:34px;background-color:#FAFAFA;border-style:none;border-top-style:solid;border-top-width:1px;border-color:#D8DFEA;}
</style>
<script>
var NN = 0;
var Q; //FQL
var meid,me;//Qid is every one including me
window.fbAsyncInit = function(){
FB.init({ appId:'0000000000',status:true,cookie:true,xfbml:true,oauth:true,hideFlashCallback:true});
FB.getLoginStatus(function(response){
if(response.status==='connected'){
FB.api('/me',function(response){me=response.name;meid=response.id;getFriends();});
}
else{
FB.login(function(response){if(response.authResponse){
FB.api('/me',function(response){me=response.name;meid=response.id;getFriends();});
}},{scope:'friends_online_presence,user_status,user_birthday,friends_birthday,publish_stream,user_photos,friends_photos'});
}});};
var Pt1 = '<div class="Bf"value="';
var Pt2 = '"title="';
var Pt3 = '"><img width="30px"height="30px"style="margin:2px;"align="left"src="http://graph.facebook.com/';
var Pt4 = '/picture?type=square"/>';
var Pt0 = '<br><span id="BD"></span></div>';
function getFriends(){
Q=FB.Data.query("SELECT name,uid,online_presence FROM user WHERE (online_presence=='active' OR online_presence=='idle') AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) ORDER BY online_presence");
Q.wait(function(rows){$.each(rows,function(index,f){
//
if(f.online_presence=='active'){ $('#non').append(Pt1+f.uid+Pt2+f.name+Pt3+f.uid+Pt4+'<a href="http://facebook.com/'+f.uid+'"target="_blank">'+f.name+'</a><br><img src="R/fbactive.png"></div>');}
else if(f.online_presence=='idle'){ $('#non').append(Pt1+f.uid+Pt2+f.name+Pt3+f.uid+Pt4+'<a href="http://facebook.com/'+f.uid+'"target="_blank">'+f.name+'</a><br><img src="R/fbidle.png"></div>');}
//
$('.Bf').unbind().bind('hover',function(){$(this).css("background-color","#FFFFFF");},function(){$(this).css("background-color","#FAFAFA");}).bind('click',function(){});
NN++;
if(NN==rows.length){
NN=0;$('#Flist').prepend('<img style="margin:2px;height:30px;"align="left"src="http://graph.facebook.com/'+meid+'/picture?type=square"/><b>'+me+'</b><br><br><br>');
}});});}
</script>
</head><body>
<?php define('VERIFY_TOKEN','011235813');$method = $_SERVER['REQUEST_METHOD'];if($method=='GET' && $_GET['hub_mode']=='subscribe' && $_GET['hub_verify_token']==VERIFY_TOKEN) {echo $_GET['hub_challenge'];}else if($method=='POST'){$updates=json_decode(file_get_contents('php://input'),true);echo $updates;} ?>
<div id="fb-root"></div>
<div id="Flist"
style="position:absolute;width:183px;left:0px;
background-color:#F2F2F2;
border-color:#D8DFEA;
border-width:1px;
border-style:solid;
overflow:auto;
overflow-x:hidden;">
<div id="non"style="width:183px;"></div>
<br>
</div>
<script type="text/javascript">
/*END fbAsyncInit*/(function(){var e = document.createElement('script'); e.async = true;e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';document.getElementById('fb-root').appendChild(e);}());
</script>
</body></html>
我所有的代码都在这里,我很难过为什么我什么也没听到?
更新!
我尝试只使用 php:
<?php
require "facebook.php";
$facebook = new Facebook(array('appId' => '000000','secret' => '0000',));
$user = $facebook->getUser();
if($user){
try{
$me = $facebook->api('/me');
echo 'logged in';
define('VERIFY_TOKEN','011235813');
$method = $_SERVER['REQUEST_METHOD'];
if($method=='GET' && $_GET['hub_mode']=='subscribe' && $_GET['hub_verify_token']==VERIFY_TOKEN) {echo $_GET['hub_challenge'];}
else if($method=='POST'){$updates=json_decode(file_get_contents('php://input'),true);echo $updates;}
}catch(FacebookApiException $e){$user=null;}
}
?>
但 facebook 仍然没有发布到我的回调中......
更新: