首页 > 其他 > 详细

利用360壁纸接口,制作精美壁纸站

时间:2020-07-26 20:06:22      阅读:106      评论:0      收藏:0      [点我收藏+]

   借鉴孟坤的360壁纸接口,确实挺好用的,制作了壁纸站,演示:http://www.sdfymj.com/so/wallpaper/

 

<?php

$cid = getParam(‘cid‘, ‘360new‘);

switch($cid)
{
    case ‘360new‘:  // 360壁纸 新图片
        $start = getParam(‘start‘, 0);
        $count = getParam(‘count‘, 10);
		echojson (file_get_contents("http://wp.birdpaper.com.cn/intf/newestList?pageno={$start}&count={$count}"));
    break;
    case ‘360tags‘:
	   echojson (file_get_contents("http://wp.birdpaper.com.cn/intf/getCategory"));
	   
    break;
    
    case ‘bing‘:
        $start = getParam(‘start‘, -1);
        $count = getParam(‘count‘, 8);
        echojson (file_get_contents("http://cn.bing.com/HPImageArchive.aspx?format=js&idx={$start}&n={$count}"));
    break;
	
	case ‘360search‘:
	    $content = getParam(‘content‘, ‘‘);
        $start = getParam(‘start‘, 0);
        $count = getParam(‘count‘, 10);
        echojson (file_get_contents("http://wp.birdpaper.com.cn/intf/search?content={$content}&pageno={$start}&count={$count}"));
    break;
    
    default:
        $start = getParam(‘start‘, 0);
        $count = getParam(‘count‘, 10);
	   echojson (file_get_contents("http://wp.birdpaper.com.cn/intf/GetListByCategory?cids={$cid}&pageno={$start}&count={$count}"));
        
}


/**
 * 获取GET或POST过来的参数
 * @param $key 键值
 * @param $default 默认值
 * @return 获取到的内容(没有则为默认值)
 */
function getParam($key,$default=‘‘)
{
    return trim($key && is_string($key) ? (isset($_POST[$key]) ? $_POST[$key] : (isset($_GET[$key]) ? $_GET[$key] : $default)) : $default);
}

/**
 * 输出一个json或jsonp格式的内容
 * @param $data 数组内容
 */
function echojson($data)    //json和jsonp通用
{
    // $callback = getParam(‘callback‘);
    // if($callback != "") //输出jsonp格式
    // {
    //     echo $callback."(".$data.")";
    // }
    // else
    // {
        echo $data;
    // }
}

  

利用360壁纸接口,制作精美壁纸站

原文:https://www.cnblogs.com/68xi/p/13380797.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!