/** * Query the Facebook Graph Api * * @param Model $model * @param $path * @param string $method GET/POST/DELETE * @param array $params * @return mixed */ public function query(Model $model, $path, $method = 'GET', $params = array()) { if ($method === 'GET') { $path = $this->buildPath($path, $params); $params = array(); } return $this->FB->api($path, $method, $params); }
private function confirm_user() { $this->loadModel("User"); //get the persons profile $user = $this->User->find("first", array("conditions" => array("User.id" => $this->Auth->User("id")))); $profile = $this->User->ensure_user_profile($user['User']['id']); $sql = "SELECT current_location FROM user where uid=me()"; //$sql = "SELECT hometown_location FROM user WHERE uid='1383222383'"; $location = FacebookApi::instance()->facebook->api(array("method" => "fql.query", "query" => $sql, "format" => "json")); $loc = $location[0]['current_location']; if (count($loc) <= 0) { //return false; } //die(print_r($location)); //update the users profile location $this->User->UserProfile->create(); $this->User->UserProfile->id = $profile['UserProfile']['id']; $update = array(); if (isset($loc['country'])) { $update['geo_country_name'] = $loc['country']; } if (isset($loc['city'])) { $update['geo_city_name'] = $loc['city']; } if (isset($loc['state'])) { $update['geo_region_name'] = $loc['state']; } return $this->User->UserProfile->save($update); }
/** * Return Singleton Instance * @return FacebookApi */ public function instance() { if (!self::$instance) { self::$instance = new self(); } return self::$instance; }
public function fb() { $fb = FacebookApi::instance(); $sql = "SELECT url, normalized_url, share_count, like_count, comment_count, total_count,\n\t\t\t\tcommentsbox_count, comments_fbid, click_count FROM link_stat WHERE url='http://theberrics.com/gen-ops/girl-chocolate-trailer.html'"; $q = $fb->facebook->api(array("method" => "fql.query", "query" => $sql, "format" => "json")); $count = $q[0]['total_count']; die($count); }
public function update_facebook_likes($id) { $entry = $this->find("first", array("conditions" => array("BangyoselfEntry.id" => $id), "contain" => array("Dailyop" => array("DailyopSection")))); $fb = FacebookApi::instance(); $sql = "SELECT url, normalized_url, share_count, like_count, comment_count, total_count,\n\t\t\t\tcommentsbox_count, comments_fbid, click_count FROM link_stat WHERE url='http://theberrics.com/{$entry['Dailyop']['DailyopSection']['uri']}/{$entry['Dailyop']['uri']}'"; $q = $fb->facebook->api(array("method" => "fql.query", "query" => $sql, "format" => "json")); $count = $q[0]['total_count']; $this->create(); $this->id = $id; $this->save(array("like_count" => $count)); }
/** * Delete (previously granted) permission * Deletes the given permission by issuing a delete request to the GraphApi * DELETE /{user-id}/permissions/{permission-name} * * @see https://developers.facebook.com/docs/facebook-login/permissions/#revoking * @param string $perm Permission name * @return bool */ public function deletePermission($perm) { $result = $this->FacebookApi->api('/me/permissions/' . (string) $perm, 'DELETE'); if (FacebookApi::$version < FacebookApi::API_VERSION_V2_1) { $result = $result === 'true' ? true : false; } if (!$result) { $this->log(__d('facebook', "Failed to delete permission '%s'.", $perm)); return false; } $this->log(__d('facebook', "Deleted permission: %s", $perm), 'info'); $this->updateUserInfo(); return true; }
public function handle_facebook_callback($callback = false) { $fb = FacebookApi::instance(); //$fb_session = $fb->facebook->getSession(); $fb_user = $fb->facebook->api("/me"); $fb_data = array("facebook_account_num" => $fb_user['id'], "first_name" => $fb_user['first_name'], "last_name" => $fb_user['last_name'], "email" => $fb_user['email'], "profile_image_url" => "http://graph.facebook.com/" . $fb_user['id'] . "/picture"); if ($callback) { $callback = base64_decode($callback); } if ($this->Session->check("here") && !$callback) { $callback = $this->Session->read("here"); } if (empty($callback) || !$callback) { $callback = "/"; } $this->userAccount = $this->User->locateLoginAccount($fb_data); $this->authAccount(); return $this->redirect($callback); }
/** * Constructor * * @throws Exception */ public function __construct() { /* if (!class_exists('Facebook')) { throw new Exception('Facebook PHP SDK not found'); } */ if (!Configure::read('Facebook')) { throw new Exception('Facebook configuration not loaded'); } // @todo implement other config params $this->config = array('appId' => Configure::read('Facebook.appId'), 'secret' => Configure::read('Facebook.appSecret')); if (self::$version > self::API_VERSION_UNVERSIONED) { $version = 'v' . self::$version; self::$DOMAIN_MAP = array('api' => 'https://api.facebook.com/' . $version . '/', 'api_video' => 'https://api-video.facebook.com/' . $version . '/', 'api_read' => 'https://api-read.facebook.com/' . $version . '/', 'graph' => 'https://graph.facebook.com/' . $version . '/', 'graph_video' => 'https://graph-video.facebook.com/' . $version . '/', 'www' => 'https://www.facebook.com/' . $version . '/', 'www-unversioned' => 'https://www.facebook.com/'); } //$this->FB = new Facebook($this->config); parent::__construct($this->config); }
/** * Builds the facebook API if we need it */ public static function buildFacebook() { if (!self::$Facebook) { self::$Facebook = new Facebook(Configure::read('Facebook.api_key'), Configure::read('Facebook.secret')); } }
public function __construct() { $this->api = FacebookApi::getInstance(); }
<?php error_reporting(E_ALL); ini_set('display_errors', true); require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/FacebookApi.php'; require_once __DIR__ . '/config.inc.php'; use Facebook\FacebookRequest; session_start(); $fb = new FacebookApi($config); $res = $fb->init(); if ($res) { header('location: index.php'); }
<pre> <?php ////////////////////////////////////////////////////////////// function autoload($class) { if (file_exists("facebook/{$class}.php")) { @(include_once "facebook/{$class}.php"); } } spl_autoload_register("autoload"); ////////////////////////////////////////////////////////////// // Create permissions... $perms = new FacebookPermissions(); $perms->user_birthday = true; // Get facebook api instance $api = FacebookApi::getInstance($perms); // If need additional perms, change them anytime // $perms->user_about_me = true; // $api->changePerms($perms); print_r($api->user); // The current user // upload a photo $p = new FacebookPhoto(); $p->addNew($api->facebook->getAccessToken(), "example.jpg", "", "A Wonder Tree!"); /* // Uncomment to create post on your wall $f = new FacebookPost; $f->message = "Teszt Elek"; $f->caption = "Teszt"; $f->description = "Teszt elek";
<?php error_reporting(E_ALL); ini_set('display_errors', true); require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/FacebookApi.php'; require_once __DIR__ . '/config.inc.php'; use Facebook\FacebookRequest; session_start(); $fb = new FacebookApi($config); $fb->init(); $accounts = $fb->getUserAccounts()->getGraphEdge(); ?> <table border="1"> <tr> <th>Id</th> <th>Page</th> <th>Token</th> </tr> <?php foreach ($accounts as $account) { ?> <tr> <td><?php echo $account->getField('id'); ?> </td> <td><?php echo $account->getField('name'); ?> </td>
/** * Builds the facebook API if we need it */ public static function buildFacebook() { if (!self::$Facebook) { self::$Facebook = new Facebook(array('appId' => Configure::read('Facebook.appId'), 'secret' => Configure::read('Facebook.secret'))); } }
/** * Require permission * @param string $perm; */ public function need($perm) { //echo $perm.": ".$this->{$perm}; if ($this->{$perm}) { return; } $p = clone $this; $p->{$perm} = true; FacebookApi::getInstance()->changePerms($p, false); }