1 Star 0 Fork 0

Jack先生/weixin

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
SearchMoive.php 1.17 KB
一键复制 编辑 原始数据 按行查看 历史
Jack先生 提交于 2017-03-23 00:08 . movie
<?php
require("./Curl.php");
class SearchMovie{
public static function GetMovie($str){
$host = "https://api.douban.com/v2/movie/search";
$query = "?q=".$str."&start=0&count=1";
$url = $host.$query;
$data = Curl::CurlGet($url);
$data = json_decode($data);
$data = self::ObjectArray($data);
return self::GetMovieInfo($data['subjects']);
}
public static function ObjectArray($array){
if(is_object($array)){
$array = (array)$array;
}
if(is_array($array)){
foreach ($array as $key => $value) {
$array[$key] = self::ObjectArray($value);
}
}
return $array;
}
public static function GetMovieInfo($arr){
$res = $arr;
$result = [];
for($i=0; $i<count($res); $i++){
$title = $res[$i]['title'];
$tag = "类型:";
foreach ($res[$i]['genres'] as $key => $value) {
$tag.=$value."/";
}
$casts = "主演:";
foreach ($res[$i]['casts'] as $key => $value) {
$casts .= $value['name'].",";
}
$result[$i] =[
'title'=>$title."[".$tag."]",
'url'=>"http://www.baidu.com",
// 'picurl'=>$value['images'][0],
'desc'=>$casts
];
}
return $result;
}
}
// $res = SearchMovie::GetMovie("宝贝计划");
?>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/jack-code-space/weixin.git
git@gitee.com:jack-code-space/weixin.git
jack-code-space
weixin
weixin
master

搜索帮助