Services_Facebook
[ class tree: Services_Facebook ] [ index: Services_Facebook ] [ all elements ]

Source for file Data.php

Documentation is available at Data.php

  1. <?php
  2.  
  3. require_once 'Services/Facebook/Common.php';
  4. require_once 'Services/Facebook/Exception.php';
  5.  
  6. {
  7.     const _PROP_TYPE_INTEGER = 1;
  8.     const _PROP_TYPE_STRING = 2;
  9.     const _PROP_TYPE_BLOB = 3;
  10.  
  11.     protected $_prefix = 'data.';
  12.  
  13.     protected function callMethod($methodarray $args = array())
  14.     {
  15.         return parent::callMethod($this->_prefix . $method$args);
  16.     }
  17.  
  18.     public function getUserPreference($pref_id
  19.     {
  20.         return $this->callMethod('getUserPreference'array(
  21.             'pref_id' => (int)$pref_id,
  22.         ));
  23.     }
  24.  
  25.     public function getUserPreferences()
  26.     {
  27.         return $this->callMethod('getUserPreferences');
  28.     }
  29.  
  30.     public function setUserPreference($pref_id$value)
  31.     {
  32.         return $this->callMethod(
  33.             'setUserPreference',
  34.             array(
  35.                 'pref_id' => $pref_id,
  36.                 'value' => $value,
  37.             )
  38.         );
  39.     }
  40.  
  41.     public function setUserPreferences()
  42.     {
  43.         throw new Services_Facebook_Exception('not yet implemented');
  44.     }
  45.  
  46.     public function createObjectType($name{
  47.         return $this->callMethod(
  48.             'createObjectType',
  49.             array(
  50.                 'name' => $name,
  51.             )
  52.         );
  53.     }
  54.  
  55.     public function dropObjectType($obj_type{
  56.         return $this->callMethod(
  57.             'dropObjectType',
  58.             array(
  59.                 'obj_type' => $obj_type,
  60.             )
  61.         );
  62.     }
  63.  
  64.     public function renameObjectType($obj_type$new_name{
  65.         return $this->callMethod(
  66.             'renameObjectType',
  67.             array(
  68.                 'obj_type' => $obj_type,
  69.                 'new_name' => $new_name,
  70.             )
  71.         );
  72.     }
  73.  
  74.     public function defineObjectProperty($obj_type$prop_name$prop_type{
  75.         // todo refactor into its own testable object
  76.         if (is_int($prop_type)) {
  77.             if (!($prop_type >= 1 && $prop_type <= 3)) {
  78.                 throw new Services_Facebook_Exception('prop_type is an invalid integer: ' $prop_type);
  79.             }
  80.         else {
  81.             $const_name 'self::_PROP_TYPE_' strtoupper($prop_type);
  82.             var_dump($const_name);
  83.             if (!defined($const_name)) {
  84.                 throw new Services_Facebook_Exception('prop_type is not a valid string: ' $prop_type);
  85.             }
  86.             $prop_type constant($const_name);
  87.         }
  88.  
  89.         return $this->callMethod(
  90.             'defineObjectProperty',
  91.             array(
  92.                 'obj_type' => $obj_type,
  93.                 'prop_name' => $prop_name,
  94.                 'prop_type' => $prop_type,
  95.             )
  96.         );
  97.     }
  98.  
  99.     public function undefineObjectProperty($obj_type$prop_name{
  100.         return $this->callMethod(
  101.             'undefineObjectProperty',
  102.             array(
  103.                 'obj_type' => $obj_type,
  104.                 'prop_name' => $prop_name,
  105.             )
  106.         );
  107.     }
  108.  
  109.     public function renameObjectProperty($obj_type$prop_name$new_name{
  110.         return $this->callMethod(
  111.             'renameObjectProperty',
  112.             array(
  113.                 'obj_type' => $obj_type,
  114.                 'prop_name' => $prop_name,
  115.                 'new_name' => $new_name,
  116.             )
  117.         );
  118.     }
  119.  
  120.     public function getObjectTypes({
  121.         return $this->callMethod('getObjectTypes');
  122.     }
  123.  
  124.     public function getObjectType($obj_type{
  125.         return $this->callMethod(
  126.             'getObjectType',
  127.             array(
  128.                 'obj_type' => $obj_type,
  129.             )
  130.         );
  131.     }
  132.  
  133.     public function createObject($obj_typearray $properties = array()) {
  134.         $args = array(
  135.             'obj_type' => $obj_type,
  136.         );
  137.         if (count($properties> 0{
  138.             $args['properties'json_encode($properties);
  139.         }
  140.  
  141.         return $this->callMethod('createObject'$args);
  142.     }
  143.  
  144.     public function updateObject($obj_idarray $properties$replace{
  145.         return $this->callMethod(
  146.             'updateObject',
  147.             array(
  148.                 'obj_id' => $obj_id,
  149.                 'properties' => json_encode($properties),
  150.                 'replace' => $replace ? 1 : 0,
  151.             )
  152.         );
  153.     }
  154.  
  155.     public function deleteObject($obj_id{
  156.         return $this->callMethod(
  157.             'deleteObject',
  158.             array(
  159.                 'obj_id' => $obj_id,
  160.             )
  161.         );
  162.     }
  163.  
  164.     public function deleteObjects(array $obj_ids{
  165.         return $this->callMethod(
  166.             'deleteObjects',
  167.             array(
  168.                 'obj_ids' => json_encode($obj_ids),
  169.             )
  170.         );
  171.     
  172.  
  173.     public function getObject($obj_idarray $properties = array()) {
  174.         if (count($properties> 0{
  175.             throw new Services_Facebook_Exception('filtering by property name doesnot seem to work...');
  176.         }
  177.         $args = array(
  178.             'obj_id' => $obj_id,
  179.         );
  180.         if (count($properties> 0{
  181.             $args['properties'json_encode($properties);
  182.         }
  183.         return $this->callMethod('getObject'$args);
  184.     }
  185.  
  186.     public function getObjects(array $obj_idsarray $properties = array()) {
  187.         $args = array(
  188.             'obj_ids' => json_encode($obj_ids),
  189.         );
  190.         if (count($properties> 0{
  191.             $args['properties'json_encode($properties);
  192.         }
  193.  
  194.         return $this->callMethod('getObjects'$args);
  195.     }
  196.  
  197.     public function getObjectProperty($obj_id$prop_name{
  198.         return $this->callMethod(
  199.             'getObjectProperty',
  200.             array(
  201.                 'obj_id' => $obj_id,
  202.                 'prop_name' => $prop_name,
  203.             )
  204.         );
  205.     }
  206.  
  207.     public function setObjectProperty($obj_id$prop_name$prop_value{
  208.         return $this->callMethod(
  209.             'setObjectProperty',
  210.             array(
  211.                 'obj_id' => $obj_id,
  212.                 'prop_name' => $prop_name,
  213.                 'prop_value' => $prop_value,
  214.             )
  215.         );
  216.     }
  217.  
  218.     public function getHashValue({
  219.         throw new Services_Facebook_Exception(__METHOD__ . ' not yet implemented');
  220.     }
  221.  
  222.     public function setHashValue({
  223.         throw new Services_Facebook_Exception(__METHOD__ . ' not yet implemented');
  224.     }
  225.  
  226.     public function incHashValue({
  227.         throw new Services_Facebook_Exception(__METHOD__ . ' not yet implemented');
  228.     }
  229.  
  230.     public function removeHashKey({
  231.         throw new Services_Facebook_Exception(__METHOD__ . ' not yet implemented');
  232.     }
  233.  
  234.     public function removeHashKeys({
  235.         throw new Services_Facebook_Exception(__METHOD__ . ' not yet implemented');
  236.     }
  237. }

Documentation generated on Mon, 11 Mar 2019 15:36:58 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.