Example #1
0
 public static function parse($response)
 {
     if (!is_array($response)) {
         Tag::setof($response, $response, "hash");
     }
     $obj = new self();
     return $obj->cp($response);
 }
Example #2
0
 public static function parse($response)
 {
     if (!is_array($response)) {
         $response = Text::parse_json($response);
     }
     $obj = new self();
     return $obj->cp($response);
 }
Example #3
0
 public static function parse_list($response)
 {
     $result = array();
     $res = Text::parse_json($response);
     foreach ($res as $re) {
         $obj = new self();
         $result[] = $obj->cp($re);
     }
     return $result;
 }
Example #4
0
 public static function parse_update($response)
 {
     $result = array();
     $re = Text::parse_json($response);
     if (isset($re["error"])) {
         throw new Exception($res["error"]);
     }
     $obj = new self();
     return $obj->cp($re);
 }
Example #5
0
 public static function parse($response)
 {
     if (Tag::setof($tag, $response, "err")) {
         throw new Exception($tag->inParam("msg"));
     }
     if (Tag::setof($tag, $response, "rsp")) {
         $obj = new self();
         return $obj->cp($tag->hash());
     }
     throw new InvalidArgumentException();
 }
Example #6
0
 public static function parse($response)
 {
     if (!is_array($response)) {
         if (Tag::setof($tag, $response, "error")) {
             throw new Exception($tag->value());
         }
         Tag::setof($tag, $response, "user");
         $response = $tag->hash();
     }
     $obj = new self();
     return $obj->cp($response);
 }
Example #7
0
 public static function parse_list($response)
 {
     $result = array();
     if (Tag::setof($tag, $response, "info")) {
         foreach ($tag->in("photo") as $photo) {
             $obj = new self();
             $result[] = $obj->cp($photo->hash());
         }
     } else {
         throw new Exception("Invalid data");
     }
     return $result;
 }
Example #8
0
 public static function parse($response)
 {
     if (Tag::setof($tag, $response, "error")) {
         throw new Exception($tag->value());
     }
     if (Tag::setof($tag, $response, "status")) {
         $hash = $tag->hash();
         $obj = new self();
         $obj->user(TwitterUser::parse($hash["user"]));
         unset($hash["user"]);
         return $obj->cp($hash);
     }
     throw new Exception("invalid data");
 }
Example #9
0
 public static function parse_list($response)
 {
     $result = array();
     if (Tag::setof($tag, $response, "error")) {
         throw new Exception($tag->f("message.value()"));
     }
     if (Tag::setof($tag, $response, "programs")) {
         foreach ($tag->in("program") as $program) {
             $obj = new self();
             $result[] = $obj->cp($program->hash());
         }
     }
     return $result;
 }
Example #10
0
 public static function parse_list($response)
 {
     $result = array();
     if (Tag::setof($tag, $response, "photos")) {
         foreach ($tag->in("photo") as $photo) {
             $obj = new self();
             $params = array();
             foreach ($photo->arParam() as $param) {
                 $params[$param[0]] = $param[1];
             }
             $result[] = $obj->cp($params);
         }
     }
     return $result;
 }
Example #11
0
 public static function parse_list($response)
 {
     $result = array();
     $res = Text::parse_json($response);
     if (!isset($res)) {
         throw new Exception($response);
     }
     if (isset($res["channels"])) {
         foreach ($res["channels"] as $re) {
             $obj = new self();
             $result[] = $obj->cp($re);
         }
     }
     return $result;
 }
Example #12
0
 public static function parse_list($response)
 {
     $result = array();
     $res = Text::parse_json($response);
     if (!isset($res)) {
         throw new Exception($response);
     }
     foreach ($res as $re) {
         $obj = new self();
         $obj->user(WassrUser::parse($re["user"]));
         unset($re["user"]);
         $result[] = $obj->cp($re);
     }
     return $result;
 }
Example #13
0
 public static function parse($response)
 {
     if (Tag::setof($tag, $response, "error")) {
         throw new Exception($tag->value());
     }
     $result = array();
     if (Tag::setof($tag, $response, "direct_message")) {
         $re = $status->hash();
         $obj = new self();
         $obj->sender(TwitterUser::parse($re["sender"]));
         $obj->recipient(TwitterUser::parse($re["recipient"]));
         unset($re["recipient"], $re["sender"]);
         return $obj->cp($re);
     }
     throw new Exception("invalid data");
 }
Example #14
0
 /**
  * RequestのPaginator
  * @param \ebi\Request $req
  * @param integer $default_paginate_by
  * @param integer $max_paginate_by
  * @return \ebi\Paginator
  */
 public static function request(\ebi\Request $req, $default_paginate_by = 20, $max_paginate_by = 100)
 {
     $paginate_by = $req->in_vars('paginate_by', $default_paginate_by);
     if ($paginate_by > $max_paginate_by) {
         $paginate_by = $max_paginate_by;
     }
     $self = new self($paginate_by, $req->in_vars('page', 1));
     if ($req->is_vars('order')) {
         $o = $req->in_vars('order');
         $p = $req->in_vars('porder');
         if ($o == $p) {
             if ($o[0] == '-') {
                 $o = substr($o, 1);
             } else {
                 $o = '-' . $o;
             }
             $req->vars('order', $o);
         }
         $self->order($o);
     }
     $self->cp($req->ar_vars());
     return $self;
 }