This commit is useless :)

This commit is contained in:
Michael Vogel 2012-05-29 16:41:20 +02:00
parent 1c955bff9b
commit ff27645c78

View file

@ -79,38 +79,38 @@ function facebook_init(&$a) {
if (x($_REQUEST, "realtime_cb") && x($_REQUEST, "realtime_cb")) {
logger("facebook_init: Facebook Real-Time callback called", LOGGER_DEBUG);
if (x($_REQUEST, "hub_verify_token")) {
// this is the verification callback while registering for real time updates
$verify_token = get_config('facebook', 'cb_verify_token');
if ($verify_token != $_REQUEST["hub_verify_token"]) {
logger('facebook_init: Wrong Facebook Callback Verifier - expected ' . $verify_token . ', got ' . $_REQUEST["hub_verify_token"]);
return;
}
if (x($_REQUEST, "hub_challenge")) {
logger('facebook_init: Answering Challenge: ' . $_REQUEST["hub_challenge"], LOGGER_DATA);
echo $_REQUEST["hub_challenge"];
die();
}
}
require_once('include/items.php');
// this is a status update
$content = file_get_contents("php://input");
if (is_numeric($content)) $content = file_get_contents("php://input");
$js = json_decode($content);
logger(print_r($js, true), LOGGER_DATA);
if (!isset($js->object) || $js->object != "user" || !isset($js->entry)) {
logger('facebook_init: Could not parse Real-Time Update data', LOGGER_DEBUG);
return;
}
$affected_users = array("feed" => array(), "friends" => array());
foreach ($js->entry as $entry) {
$fbuser = $entry->uid;
foreach ($entry->changed_fields as $field) {
@ -119,20 +119,20 @@ function facebook_init(&$a) {
continue;
}
if (in_array($fbuser, $affected_users[$field])) continue;
$r = q("SELECT `uid` FROM `pconfig` WHERE `cat` = 'facebook' AND `k` = 'self_id' AND `v` = '%s' LIMIT 1", dbesc($fbuser));
if(! count($r))
continue;
$uid = $r[0]['uid'];
$access_token = get_pconfig($uid,'facebook','access_token');
if(! $access_token)
return;
switch ($field) {
case "feed":
logger('facebook_init: FB-User ' . $fbuser . ' / feed', LOGGER_DEBUG);
if(! get_pconfig($uid,'facebook','no_wall')) {
$private_wall = intval(get_pconfig($uid,'facebook','private_wall'));
$s = fetch_url('https://graph.facebook.com/me/feed?access_token=' . $access_token);
@ -146,11 +146,11 @@ function facebook_init(&$a) {
}
}
}
break;
case "friends":
logger('facebook_init: FB-User ' . $fbuser . ' / friends', LOGGER_DEBUG);
fb_get_friends($uid, false);
set_pconfig($uid,'facebook','friend_check',time());
break;
@ -162,7 +162,7 @@ function facebook_init(&$a) {
}
}
if($a->argc != 2)
return;
$nick = $a->argv[1];
@ -188,7 +188,7 @@ function facebook_init(&$a) {
$x = fetch_url('https://graph.facebook.com/oauth/access_token?client_id='
. $appid . '&client_secret=' . $appsecret . '&redirect_uri='
. urlencode($a->get_baseurl() . '/facebook/' . $nick)
. urlencode($a->get_baseurl() . '/facebook/' . $nick)
. '&code=' . $auth_code);
logger('facebook_init: returned access token: ' . $x, LOGGER_DATA);
@ -404,6 +404,7 @@ function fb_get_friends($uid, $fullsync = true) {
$access_token = get_pconfig($uid,'facebook','access_token');
$no_linking = get_pconfig($uid,'facebook','no_linking');
if($no_linking)
return;
@ -428,7 +429,7 @@ function fb_get_friends($uid, $fullsync = true) {
}
// This is the POST method to the facebook settings page
// Content is posted to Facebook in the function facebook_post_hook()
// Content is posted to Facebook in the function facebook_post_hook()
/**
* @param App $a
@ -439,7 +440,7 @@ function facebook_post(&$a) {
if($uid){
$fb_limited = get_config('facebook','restrict');
$fb_limited = get_config('facebook','crestrict');
$value = ((x($_POST,'post_by_default')) ? intval($_POST['post_by_default']) : 0);
@ -452,7 +453,7 @@ function facebook_post(&$a) {
$private_wall = ((x($_POST,'facebook_private_wall')) ? intval($_POST['facebook_private_wall']) : 0);
set_pconfig($uid,'facebook','private_wall',$private_wall);
set_pconfig($uid,'facebook','blocked_apps',escape_tags(trim($_POST['blocked_apps'])));
@ -462,7 +463,7 @@ function facebook_post(&$a) {
if($linkvalue == 0)
set_pconfig($uid,'facebook','no_linking', 1);
}
else
else
set_pconfig($uid,'facebook','no_linking', (($linkvalue) ? 0 : 1));
// FB linkage was allowed but has just been turned off - remove all FB contacts and posts