当前位置: 首页>>代码示例>>PHP>>正文


PHP Text::parse_json方法代码示例

本文整理汇总了PHP中Text::parse_json方法的典型用法代码示例。如果您正苦于以下问题:PHP Text::parse_json方法的具体用法?PHP Text::parse_json怎么用?PHP Text::parse_json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Text的用法示例。


在下文中一共展示了Text::parse_json方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parse

 public static function parse($response)
 {
     if (!is_array($response)) {
         $response = Text::parse_json($response);
     }
     $obj = new self();
     return $obj->cp($response);
 }
开发者ID:hisaboh,项目名称:w2t,代码行数:8,代码来源:WassrUser.php

示例2: parse_list

 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;
 }
开发者ID:hisaboh,项目名称:w2t,代码行数:10,代码来源:WassrTodo.php

示例3: parse_update

 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);
 }
开发者ID:hisaboh,项目名称:w2t,代码行数:10,代码来源:WassrChannelMessage.php

示例4: parse_list

 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;
 }
开发者ID:hisaboh,项目名称:w2t,代码行数:15,代码来源:WassrChannel.php

示例5: parse_list

 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;
 }
开发者ID:hisaboh,项目名称:w2t,代码行数:15,代码来源:WassrMessage.php

示例6: download

 public function download($save_dir, $save_filename, $ext = true)
 {
     $b = new Http();
     $b->do_get($this->url() . "&fmt=22");
     if (preg_match("/var[\\s]+swfArgs[\\s]*=[\\s]*(\\{.+?\\})/m", $b->body(), $match)) {
         $json = Text::parse_json($match[1]);
         $base_url = "http://www.youtube.com/get_video?video_id=" . $json["video_id"] . "&t=" . $json["t"];
         $url = $base_url . "&fmt=22";
         if ($b->do_head($url)->status() !== 200) {
             $url = $base_url . "&fmt=18";
         }
         $b->do_download($url, File::absolute($save_dir, $save_filename) . ($ext ? $this->ext : ""));
         return;
     }
     throw new Exception("undef video");
 }
开发者ID:hisaboh,项目名称:w2t,代码行数:16,代码来源:YouTubeDataResult.php

示例7: parse_list

 public static function parse_list($response)
 {
     $result = array();
     $res = Text::parse_json($response);
     if (!isset($res["responseData"]["results"])) {
         throw new Exception("Invalid data");
     }
     foreach ($res["responseData"]["results"] as $re) {
         $obj = new self();
         $obj->cache_url($re["cacheUrl"]);
         $obj->url($re["unescapedUrl"]);
         $obj->title($re["titleNoFormatting"]);
         $obj->content($re["content"]);
         $result[] = $obj;
     }
     return $result;
 }
开发者ID:hisaboh,项目名称:w2t,代码行数:17,代码来源:GoogleSearchResult.php

示例8: parse_list

 public static function parse_list($response, $paginator)
 {
     $result = array();
     $res = Text::parse_json($response);
     if (isset($res["error"])) {
         throw new Exception($res["error"]);
     }
     if (!empty($res["pager"])) {
         $paginator = new Paginator($res["pager"]["clips_in_page"], $res["pager"]["current_page"], $res["pager"]["total_entries"]);
     }
     if (!empty($res["entries"])) {
         foreach ($res["entries"] as $re) {
             $obj = new self();
             $obj->id($re["id"]);
             $obj->title($re["title"]);
             $obj->url($re["permalink"]);
             $obj->author(new FlipClipAuthor($re["author"]["id"], $re["author"]["name"], $re["author"]["uri"]));
             $obj->summary($re["summary"]);
             $obj->updated($re["updated"]);
             if (isset($re["category"])) {
                 $obj->category(new FlipClipCategory($re["category"]["term"], $re["category"]["scheme"], $re["category"]["label"]));
             }
             if (isset($re["subcategory"])) {
                 $obj->category(new FlipClipCategory($re["subcategory"]["term"], $re["subcategory"]["scheme"], $re["subcategory"]["label"]));
             }
             if (isset($re["tags"])) {
                 foreach ($re["tags"] as $tag) {
                     $obj->tags(new FlipClipTag($tag["term"], $tag["scheme"], $tag["label"]));
                 }
             }
             $obj->embed_script($re["embed_script"]);
             $obj->latitude($re["latitude"]);
             $obj->longitude($re["longitude"]);
             $obj->privacy($re["privacy"]);
             $obj->duration($re["duration"]);
             $obj->image($re["image"]);
             $obj->image_medium($re["imageMedium"]);
             $obj->image_small($re["imageSmall"]);
             $obj->thumbnail($re["thumbnail"]);
             $result[] = $obj;
         }
     }
     return $result;
 }
开发者ID:hisaboh,项目名称:w2t,代码行数:44,代码来源:FlipClipSearchResult.php

示例9: trans

 /**
  * 翻訳
  *  言語コード http://code.google.com/intl/ja-JP/apis/ajaxlanguage/documentation/reference.html#LangNameArray
  *
  * @param 翻訳対象文字列 $word
  * @param 翻訳後言語コード $to
  * @param 翻訳前言語コード $from
  * @return string
  */
 public function trans($word, $to, $from = null)
 {
     $this->vars("q", $word);
     $this->vars("v", "1.0");
     $this->vars("langpair", $from . "|" . $to);
     $this->do_get("language/translate");
     $result = Text::parse_json($this->body());
     if (isset($result["responseStatus"])) {
         if ($result["responseStatus"] !== 200) {
             throw new Exception($result["responseDetails"]);
         }
         return $result["responseData"]["translatedText"];
     }
     throw new Exception("invalid response");
     /***
     			$api = new GoogleAPI();
     			try{
     				$result = $api->trans("frog","ja");
     				eq(true,true);
     			}catch(Exception $e){
     				eq(false,$e->getMessage());
     			}
     		 */
 }
开发者ID:hisaboh,项目名称:w2t,代码行数:33,代码来源:GoogleAPI.php

示例10: post

 private function post($url)
 {
     $this->do_post($url);
     $res = Text::parse_json($this->body());
     if (isset($res["error"])) {
         throw new Exception($res["error"]);
     }
 }
开发者ID:hisaboh,项目名称:w2t,代码行数:8,代码来源:WassrAPI.php


注:本文中的Text::parse_json方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。