示例#1
0
文件: auth.php 项目: annaqin/eden
 public function __construct($key, $secret, $redirect)
 {
     //argument test
     Eden_Facebook_Error::i()->argument(1, 'string')->argument(2, 'string')->argument(3, 'string');
     //Argument 4 must be a string
     parent::__construct($key, $secret, $redirect, self::REQUEST_URL, self::ACCESS_URL);
 }
示例#2
0
 public function subscribe($object, $aspect, $callback_url)
 {
     Eden_Facebook_Error::i()->argument(1, 'string')->argument(2, 'string')->argument(3, 'string');
     $results = $this->_post(self::API_URL, array('client_id' => $this->_client_id, 'client_secret' => $this->_client_secret, 'object' => $object, 'aspect' => $aspect, 'verify_token' => self::_getVerifyToken($this->_client_id, $object, $callback_url), 'callback_url' => $callback_url));
     return $results;
 }
示例#3
0
文件: event.php 项目: brynner/postr
 /**
  * Sets the venue street
  *
  * @param string
  * @return this
  */
 public function setStreet($street)
 {
     //Argument 1 must be a string
     Eden_Facebook_Error::i()->argument(1, 'string');
     $this->_venue['street'] = $street;
     return $this;
 }
示例#4
0
 /**
  * Subscribes to Facebook real-time updates
  * 
  * @param string Type of Facebook object (user, permissions, page)
  * @param string Comma-deliminated list of fields to subscribe to (e.g. "name,picture,friends,feed")
  * @param url Callback-url for the real-time updates
  */
 public function subscribe($object, $fields, $callbackUrl)
 {
     //argument test
     Eden_Facebook_Error::i()->argument(1, 'string')->argument(2, 'string')->argument(3, 'url');
     //populate fields
     $query = array('object' => $object, 'fields' => $fields, 'callback_url' => $callbackUrl, 'verify_token' => sha1($this->_appId . $object . $callbackUrl));
     //generate url
     $token = array('access_token' => $this->_token);
     $url = sprintf(self::SUBSCRIBE_URL, $this->_appId) . '?' . http_build_query($token);
     return $this->_post($url, $query);
 }
示例#5
0
文件: search.php 项目: brynner/postr
 /**
  * Sets Table
  * 
  * @param string
  * @return this
  */
 public function setTable($table)
 {
     Eden_Facebook_Error::i()->argument(1, 'string');
     $this->_table = $table;
     return $this;
 }
示例#6
0
文件: fql.php 项目: brynner/postr
 /**
  * Returns the select query builder
  *
  * @return Eden_Facebook_Select
  */
 public function select($select = '*')
 {
     //Argument 1 must be a string or array
     Eden_Facebook_Error::i()->argument(1, 'string', 'array');
     return Eden_Facebook_Select::i($select);
 }
示例#7
0
文件: graph.php 项目: brynner/postr
 /**
  * Uploads a file of your album
  *
  * @param int|string
  * @param string
  * @param string|null
  * @return int photo ID
  */
 public function uploadPhoto($albumId, $file, $message = NULL)
 {
     //Argument test
     Eden_Facebook_Error::i()->argument(1, 'string', 'int')->argument(2, 'file')->argument(3, 'string', 'null');
     //Argument 3 must be a string or null
     //form the URL
     $url = self::GRAPH_URL . $albumId . '/photos';
     $post = array('source' => '@' . $file);
     $query = array('access_token' => $this->_token);
     //if there is a message
     if ($message) {
         $post['message'] = $message;
     }
     $url .= '?' . http_build_query($query);
     //send it off
     $results = Eden_Curl::i()->setUrl($url)->setConnectTimeout(10)->setFollowLocation(true)->setTimeout(60)->verifyPeer(false)->setUserAgent(Eden_Facebook_Auth::USER_AGENT)->setHeaders('Expect')->when(!empty($post), 2)->setPost(true)->setPostFields($post)->getJsonResponse();
     return $results['id'];
 }
示例#8
0
 /**
  * Returns an RSS feed to a public id
  *
  * @param int
  * @return SimpleXml
  */
 public function rss($id)
 {
     Eden_Facebook_Error::i()->argument(1, 'int');
     return Eden_Curl::i()->setUrl(sprintf(self::RSS, $id))->setUserAgent(self::RSS_AGENT)->setConnectTimeout(10)->setFollowLocation(true)->setTimeout(60)->verifyPeer(false)->getSimpleXmlResponse();
 }
 /**
  * Sets a picture
  *
  * @param string
  * @return this
  */
 public function setPicture($picture)
 {
     //Argument 1 must be a string
     Eden_Facebook_Error::i()->argument(1, 'url');
     $this->_post['picture'] = $picture;
     return $this;
 }
示例#10
0
文件: yql.php 项目: brynner/postr
 /**
  * Queries the database
  * 
  * @param string query
  * @return array|object
  */
 public function query($query)
 {
     //Argument 1 must be a string or null
     Eden_Yahoo_Error::i()->argument(1, 'string', 'array', self::SELECT);
     if (!is_array($query)) {
         $query = array('q' => (string) $query);
     } else {
         foreach ($query as $key => $select) {
             $query[$key] = (string) $select;
         }
         $query = array('q' => json_encode($query));
     }
     $query['access_token'] = $this->_token;
     $url = str_replace('+', '%20', self::YQL_URL . '?' . http_build_query($query + array('format' => 'json')));
     $results = Eden_Curl::i()->setUrl($url)->setConnectTimeout(10)->setFollowLocation(true)->setTimeout(60)->verifyPeer(false)->setUserAgent(Eden_Facebook_Auth::USER_AGENT)->setHeaders('Expect')->getJsonResponse();
     $this->_queries[] = array('query' => $query['q'], 'results' => $results);
     if (isset($results['error']['message'])) {
         Eden_Facebook_Error::i($query['q'] . $results['error']['message'])->trigger();
     }
     return $results;
 }
 /**
  * sets the video to your post
  *
  * @param string
  * @return this
  */
 public function setVideo($url)
 {
     //Argument 1 must be a string
     Eden_Facebook_Error::i()->argument(1, 'url');
     $this->_post['video'] = $url;
     return $this;
 }
示例#12
0
 /**
  * Where clause
  *
  * @param array|string where
  * @return	this
  * @notes loads a where phrase into registry
  */
 public function where($where)
 {
     //Argument 1 must be a string or array
     Eden_Facebook_Error::i()->argument(1, 'string', 'array');
     if (is_string($where)) {
         $where = array($where);
     }
     $this->_where = array_merge($this->_where, $where);
     return $this;
 }
示例#13
0
if(!class_exists('Eden_Facebook_Fql')){class Eden_Facebook_Fql extends Eden_Class{const SELECT='Eden_Facebook_Select';const FQL_URL='https://graph.facebook.com/fql';protected $_queries=array();protected $_token=NULL;public static function i(){return self::_getMultiple(__CLASS__);}public function __construct($token){$this->_token=$token;}public function getCollection($table,$filters=NULL,array $sort=array(),$start=0,$range=0,$index=NULL){Eden_Facebook_Error::i()->argument(1,'string')->argument(2,'string','array','null')->argument(4,'numeric')->argument(5,'numeric')->argument(6,'numeric','null');$results=$this->getRows($table,$filters,$sort,$start,$range,$index);$collection=Eden_Collection::i();if(is_null($results)){return $collection;}if(!is_null($index)){return $this->model($results);}return $collection->set($results);}public function getModel($table,$name,$value){Eden_Facebook_Error::i()->argument(1,'string')->argument(2,'string')->argument(3,'string','numeric');$result=$this->getRow($table,$name,$value);$model=Eden_Model::i();if(is_null($result)){return $model;}return $model->set($result);}public function getRow($table,$name,$value){Eden_Facebook_Error::i()->argument(1,'string')->argument(2,'string')->argument(3,'string','numeric');$query=$this->select()->from($table)->where($name.'='.$value)->limit(0,1);$results=$this->query($query);return isset($results[0]) ? $results[0] : NULL;}public function getRows($table,$filters=NULL,array $sort=array(),$start=0,$range=0,$index=NULL){Eden_Facebook_Error::i()->argument(1,'string')->argument(2,'string','array','null')->argument(4,'numeric')->argument(5,'numeric')->argument(6,'numeric','null');$query=$this->select()->from($table);if(is_array($filters)){foreach($filters as $i=>$filter){if(!is_array($filter)){continue;}$format=array_shift($filter);$filters[$i]=vsprintf($format,$filter);}}if(!is_null($filters)){$query->where($filters);}if(!empty($sort)){foreach($sort as $key=>$value){if(is_string($key) && trim($key)){$query->sortBy($key,$value);}}}if($range){$query->limit($start,$range);}$results=$this->query($query);if(!is_null($index)){if(empty($results)){$results=NULL;}else{if($index==self::FIRST){$index=0;}if($index==self::LAST){$index=count($results)-1;}if(isset($results[$index])){$results=$results[$index];}else{$results=NULL;}}}return $results;}public function getRowsCount($table,$filters=NULL){Eden_Facebook_Error::i()->argument(1,'string')->argument(2,'string','array','null');$query=$this->select('COUNT(*) as count')->from($table);if(is_array($filters)){foreach($filters as $i=>$filter){if(!is_array($filter)){continue;}$format=array_shift($filter);$filters[$i]=vsprintf($format,$filter);}}if(!is_null($filters)){$query->where($filters);}$results=$this->query($query);if(isset($results[0]['count'])){return $results[0]['count'];}return false;}public function getQueries($index=NULL){if(is_null($index)){return $this->_queries;}if($index==self::FIRST){$index=0;}if($index==self::LAST){$index=count($this->_queries) - 1;}if(isset($this->_queries[$index])){return $this->_queries[$index];}return NULL;}public function query($query){Eden_Facebook_Error::i()->argument(1,'string','array',self::SELECT);if(!is_array($query)){$query=array('q'=>(string) $query);}else{foreach($query as $key=>$select){$query[$key]=(string) $select;}$query=array('q'=>json_encode($query));}$query['access_token']=$this->_token;$url=self::FQL_URL.'?'.http_build_query($query);$results=Eden_Curl::i()->setUrl($url)->setConnectTimeout(10)->setFollowLocation(true)->setTimeout(60)->verifyPeer(false)->setUserAgent(Eden_Facebook_Auth::USER_AGENT)->setHeaders('Expect')->getJsonResponse();$this->_queries[]=array( 'query'=>$query['q'],'results'=>$results);if(isset($results['error']['message'])){Eden_Facebook_Error::i($query['q'].$results['error']['message'])->trigger();}return $results['data'];}public function search(){return Eden_Facebook_Search::i($this);}public function select($select='*'){Eden_Facebook_Error::i()->argument(1,'string','array');return Eden_Facebook_Select::i($select);}}}
 /**
  * Subscribes to Facebook real-time updates
  *
  * @param $app_id string Facebook app_id (We need to get this from a different place somehow, doesn't seem right making it a variable)
  * @param $object string type of Facebook object (user, permissions, page)
  * @param $fields string comma-deliminated list of fields to subscribe to (e.g. "name,picture,friends,feed")
  * @param $callback_url - callback-url for the real-time updates
  */
 public function subscribe($app_id, $object, $fields, $callback_url)
 {
     Eden_Facebook_Error::i()->argument(1, 'string')->argument(2, 'string')->argument(3, 'string');
     $url = self::GRAPH_URL . "{$app_id}/subscriptions";
     $query = array('access_token' => $this->_token);
     $url .= '?' . http_build_query($query);
     $verify_token = sha1($app_id . $object . $callback_url);
     $post = array('object' => $object, 'fields' => $fields, 'callback_url' => $callback_url, 'verify_token' => $verify_token);
     //send it off
     $results = Eden_Curl::i()->setUrl($url)->setConnectTimeout(10)->setFollowLocation(true)->setTimeout(60)->verifyPeer(false)->setUserAgent(Eden_Facebook_Auth::USER_AGENT)->setHeaders('Expect')->setPost(true)->setPostFields($post)->getJsonResponse();
     return $verify_token;
 }