您的位置:首页 > 移动开发 > 微信开发

电影热搜API及微信菜单自定义开发

2017-11-02 21:03 99 查看
热搜电影API

$movieApi = "http://api.map.baidu.com/telematics/v3/movie?qt=hot_movie&location={$jd},{$wd}&output=json&ak=SnF72fxXpr2mAaS7FBMsyC4o07YbfMvk";

$hot_movie = file_get_contents($movieApi);
$hot_movie = json_decode($hot_movie,true)['result']['movie'];
print_r( $hot_movie );
foreach ( $hot_movie as $key => $value ) {
?>
<img src="<?php echo $hot_movie[$key]['movie_picture'] ?>">
<?php
}
$tapi = "https://openapi.youku.com/v2/searches/video/by_keyword.json?";
$mode = '&keyword=' . urlencode('夺路而逃');
$key = '&client_id=d36c06a0c14be911';

$url = $tapi . $mode . $key;

$tapi = file_get_contents($url);
$tapi = json_decode($tapi,true);
print_r ($tapi);


微信菜单:

$appid = 'wx4621b6f3291a8800';
$appsecret = '5983fc4277b2fe470bab4fab18b938a1';
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$appsecret}";

$res = file_get_contents($url);
$res = json_decode($res,true);
$access_token = $res['access_token'];
echo $access_token;
$menuapi = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token={$access_token}";

$menu = '{
"button":[
{
"name":"电影搜搜",
"sub_button":[
{
"type":"view",
"name":"网盘007",
"url":"http://wangpan007.com/"
},
{
"type":"view",
"name":"搜百度云",
"url":"http://www.bdsola.com/"
},
{
"type":"view",
"name":"盘搜搜",
"url":"http://www.pansou.com/"
},{
"type":"view",
"name":"80s电影网",
"url":"https://m.80s.tw/"
}]
},
{
"name":"菜单",
"sub_button":[
{
"type":"view",
"name":"搜索",
"url":"http://www.soso.com/"
},
{
"type":"view",
"name":"视频",
"url":"http://v.qq.com/"
},
{
"type":"click",
"name":"赞一下我们",
"key":"V1001_GOOD"
}]
}]
}';

$params = array(
'http' => array(
'method' => 'POST',
'header'=> "Content-type: application/x-www-form-urlencoded\r\n"
. "Content-Length: ". strlen($menu) ."\r\n",
'content' => $menu
)
);

$ctx = stream_context_create($params);
echo file_get_contents($menuapi,false,$ctx);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息