示例#1
0
 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);
 }
示例#2
0
 /**
  * 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));
 }
 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);
 }