Ejemplo n.º 1
0
 public function create($fb_id, $name, $fb_name = null)
 {
     $fb = new FacebookCustomApi();
     $fb->data['FACEBOOKID'] = $fb_id;
     $fb->data['NAME'] = $name;
     $fb->data['FACEBOOKNAME'] = $fb_name;
     $fb->data['LASTUPDATEON'] = KdObject::now();
     /**@todo this is unsafe**/
     $fb->save();
     return $fb->id;
 }
Ejemplo n.º 2
0
<?php

header('Content-type: application/json');
require '../inc/common.php';
$fb = new FacebookCustomApi();
$new_id = $fb->create($_POST['fb-id'], $_POST['fb-name'], $_POST['kd-name']);
if (is_numeric($new_id) && $new_id != 0) {
    $return = array('status' => 'OK', 'msg' => 'Data inserted successfully', 'id' => $new_id);
} else {
    $return = array('status' => 'FAIL', 'status' => 'Fail while entering data');
}
echo json_encode($return);
Ejemplo n.º 3
0
        $event = array('TITLE' => $arr['name'], 'DESCRIPTION' => $arr['description'], 'PLACE' => $place, 'EVENTDATE' => $date, 'PLACELNGLAT' => $lnglat, 'FACEBOOKID' => $id, 'EMAIL' => '', 'URL' => '', 'FACEBOOKEVENTID' => $arr['id'], 'FACEBOOKID' => $name);
        $addEvent = new Event();
        $addEvent->create($event);
    }
}
$access_token = FB_ACCESS_TOKEN;
if (isset($_GET['ac'])) {
    $access_token = $_GET['ac'];
}
if (isset($argv[1])) {
    $access_token = $argv[1];
}
$fb = new Facebook\Facebook(['app_id' => FB_APP_ID, 'app_secret' => FB_APP_SECRET, 'default_graph_version' => 'v2.4']);
$fb->setDefaultAccessToken($access_token);
try {
    $facebookApi = new FacebookCustomApi();
    $pages = $facebookApi->getFacebookCustomApi();
    foreach ($pages as $p) {
        $response = $fb->get($p['FacebookID'] . "/events");
        $resp = json_decode($response->getBody(), true);
        foreach ($resp['data'] as $event) {
            $exists = Event::fbEventExists($event['id']);
            if (!$exists) {
                saveEvent($event, $p['FacebookID']);
            }
        }
    }
    exit;
} catch (Facebook\Exceptions\FacebookResponseException $e) {
    echo 'Graph returned an error: ' . $e->getMessage();
    exit;