每日獲取bing壁紙

字號+ 編輯: 国内TP粉 修訂: 人在硅谷 來源: ThinkPHP 2023-09-11 我要說兩句(0)

獲取每日bing的高清壁紙

直接上代碼

<?php
header("Content-Type:text/html;charset=UTF-8");
date_default_timezone_set("PRC");
$showapi_appid = 'xxxxxx';  // 替換此值,在官網的"我的應用"中找到相關值
$showapi_secret = 'xxxxxxxxx';  // 替換此值,在官網的"我的應用"中找到相關值 
$paramArr = array(
     'showapi_appid'=> $showapi_appid
     //添加其他參數
);
//創建參數(包括簽名的處理)
function createParam ($paramArr,$showapi_secret) {
     $paraStr = "";
     $signStr = "";
     ksort($paramArr);
     foreach ($paramArr as $key => $val) {
         if ($key != '' && $val != '') {
             $signStr .= $key.$val;
             $paraStr .= $key.'='.urlencode($val).'&';
         }
     }
     $signStr .= $showapi_secret;//排好序的參數加上secret,進行md5
     $sign = strtolower(md5($signStr));
     $paraStr .= 'showapi_sign='.$sign;//將md5後的值作爲參數,便於服務器的效驗
     echo "排好序的參數:".$signStr."<br>\r\n";
     return $paraStr;
}
$param = createParam($paramArr,$showapi_secret);
$url = 'http://route.showapi.com/1377-1?'.$param;  
echo "請求的url:".$url."<br>\r\n";
$result = file_get_contents($url);
echo "返回的json數據:<br>\r\n";
print $result.'<br>\r\n';
$result = json_decode($result);
echo "<br>\r\n取出showapi_res_code的值:<br>\r\n";
print_r($result->showapi_res_code);
echo "<br>\r\n";
?>
{
  "showapi_res_code": 0,
  "showapi_res_error": "",
  "showapi_res_body": {
    "ret_code": 0,
    "list": [
      {
        "1920*1080": "http://www.bing.com/az/hprichbg/rb/StorkCliffs_ZH-CN11006532238_1920*1080.jpg",
        "720x1280": "http://www.bing.com/az/hprichbg/rb/StorkCliffs_ZH-CN11006532238_720x1280.jpg",
        "800x600": "http://www.bing.com/az/hprichbg/rb/StorkCliffs_ZH-CN11006532238_800x600.jpg",
        "pic": "http://www.bing.com/az/hprichbg/rb/StorkCliffs_ZH-CN11006532238_1920x1080.jpg",
        "640x480": "http://www.bing.com/az/hprichbg/rb/StorkCliffs_ZH-CN11006532238_640x480.jpg",
        "240x320": "http://www.bing.com/az/hprichbg/rb/StorkCliffs_ZH-CN11006532238_240x320.jpg",
        "country": "法國",
        "city": "霞慕尼山谷",
        "content": "在法國的霞慕尼山谷的上空,這種發光的隂霾看起來像仙境幻想,但它確實是怪異天氣的産物。當下面的溫度比上面的空氣溫度低的時候,會發生這樣的反轉,看起來像一片雲的海洋。在這個特殊的雲層下面是鼕季運動愛好者的遊樂場。霞慕尼是法國最古老的滑雪勝地之一。",
        "title": "一隻白鸛和幼鳥在阿連特茹西南部和維森蒂娜海岸自然公園内築巢,葡萄牙 (© Marco Bustos/Solent News/REX/Shutterstock)",
        "320x240": "http://www.bing.com/az/hprichbg/rb/StorkCliffs_ZH-CN11006532238_320x240.jpg",
        "subtitle": "法國,霞慕尼山谷",
        "1024x768": "http://www.bing.com/az/hprichbg/rb/StorkCliffs_ZH-CN11006532238_1024x768.jpg",
        "400x240": "http://www.bing.com/az/hprichbg/rb/StorkCliffs_ZH-CN11006532238_400x240.jpg",
        "day": "20170831",
        "1280x768": "http://www.bing.com/az/hprichbg/rb/StorkCliffs_ZH-CN11006532238_1280x768.jpg",
        "480x800": "http://www.bing.com/az/hprichbg/rb/StorkCliffs_ZH-CN11006532238_480x800.jpg",
        "800x480": "http://www.bing.com/az/hprichbg/rb/StorkCliffs_ZH-CN11006532238_800x480.jpg",
        "1366x768": "http://www.bing.com/az/hprichbg/rb/StorkCliffs_ZH-CN11006532238_1366x768.jpg"
      },
      {
        "1920*1080": "http://www.bing.com/az/hprichbg/rb/ChamonixClouds_ZH-CN7700889231_1920*1080.jpg",
        "720x1280": "http://www.bing.com/az/hprichbg/rb/ChamonixClouds_ZH-CN7700889231_720x1280.jpg",
        "800x600": "http://www.bing.com/az/hprichbg/rb/ChamonixClouds_ZH-CN7700889231_800x600.jpg",
        "pic": "http://www.bing.com/az/hprichbg/rb/ChamonixClouds_ZH-CN7700889231_1920x1080.jpg",
        "640x480": "http://www.bing.com/az/hprichbg/rb/ChamonixClouds_ZH-CN7700889231_640x480.jpg",
        "240x320": "http://www.bing.com/az/hprichbg/rb/ChamonixClouds_ZH-CN7700889231_240x320.jpg",
        "country": "",
        "city": "",
        "content": "這群金色無齒鯵與海洋中最大的魚——鯨鯊一起在鳥頭灣悠閑的遨遊。金色無齒鯵經常與溫和的巨人鯨鯊一起遊泳,它們能清除一些鯨鯊的殘羹剩飯,甚至可以保護鯨鯊免受捕食者的傷害。與大多數鯊魚不同,鯨鯊是一種以浮遊生物爲食的濾食動物。我們可以在赤道附近的溫暖水域裡找到它們。",
        "title": "法國霞慕尼山谷上空的雲海 (© Masterfile)",
        "320x240": "http://www.bing.com/az/hprichbg/rb/ChamonixClouds_ZH-CN7700889231_320x240.jpg",
        "subtitle": "奇妙的旅程",
        "1024x768": "http://www.bing.com/az/hprichbg/rb/ChamonixClouds_ZH-CN7700889231_1024x768.jpg",
        "400x240": "http://www.bing.com/az/hprichbg/rb/ChamonixClouds_ZH-CN7700889231_400x240.jpg",
        "day": "20170830",
        "1280x768": "http://www.bing.com/az/hprichbg/rb/ChamonixClouds_ZH-CN7700889231_1280x768.jpg",
        "480x800": "http://www.bing.com/az/hprichbg/rb/ChamonixClouds_ZH-CN7700889231_480x800.jpg",
        "800x480": "http://www.bing.com/az/hprichbg/rb/ChamonixClouds_ZH-CN7700889231_800x480.jpg",
        "1366x768": "http://www.bing.com/az/hprichbg/rb/ChamonixClouds_ZH-CN7700889231_1366x768.jpg"
      },
      {
        "1920*1080": "http://www.bing.com/az/hprichbg/rb/GoldenTrevally_ZH-CN8976794546_1920*1080.jpg",
        "720x1280": "http://www.bing.com/az/hprichbg/rb/GoldenTrevally_ZH-CN8976794546_720x1280.jpg",
        "800x600": "http://www.bing.com/az/hprichbg/rb/GoldenTrevally_ZH-CN8976794546_800x600.jpg",
        "pic": "http://www.bing.com/az/hprichbg/rb/GoldenTrevally_ZH-CN8976794546_1920x1080.jpg",
        "640x480": "http://www.bing.com/az/hprichbg/rb/GoldenTrevally_ZH-CN8976794546_640x480.jpg",
        "240x320": "http://www.bing.com/az/hprichbg/rb/GoldenTrevally_ZH-CN8976794546_240x320.jpg",
        "country": "",
        "city": "",
        "content": "時間的流逝在俄勒岡州中部的彩繪山丘上留下了它的痕跡,這是約翰時代化石床國家紀念碑的一部分。色彩斑斕的灰土講述了一個大約3000萬年前的一個時代的故事,當時該地區是一個富饒的洪水平原,有馬、駱駝、甚至犀牛等動物。它們的化石殘骸都可以在這裡找到,吸引了古生物學家和大量的遊客。",
        "title": "一群金色無齒鯵與一條鯨鯊遨遊在鳥頭灣中,印度尼西亞 (© Pete Oxford/Minden Pictures)",
        "320x240": "http://www.bing.com/az/hprichbg/rb/GoldenTrevally_ZH-CN8976794546_320x240.jpg",
        "subtitle": "彩繪山丘",
        "1024x768": "http://www.bing.com/az/hprichbg/rb/GoldenTrevally_ZH-CN8976794546_1024x768.jpg",
        "400x240": "http://www.bing.com/az/hprichbg/rb/GoldenTrevally_ZH-CN8976794546_400x240.jpg",
        "day": "20170829",
        "1280x768": "http://www.bing.com/az/hprichbg/rb/GoldenTrevally_ZH-CN8976794546_1280x768.jpg",
        "480x800": "http://www.bing.com/az/hprichbg/rb/GoldenTrevally_ZH-CN8976794546_480x800.jpg",
        "800x480": "http://www.bing.com/az/hprichbg/rb/GoldenTrevally_ZH-CN8976794546_800x480.jpg",
        "1366x768": "http://www.bing.com/az/hprichbg/rb/GoldenTrevally_ZH-CN8976794546_1366x768.jpg"
      },
      {
        "1920*1080": "http://www.bing.com/az/hprichbg/rb/OregonPainted_ZH-CN8553728911_1920*1080.jpg",
        "720x1280": "http://www.bing.com/az/hprichbg/rb/OregonPainted_ZH-CN8553728911_720x1280.jpg",
        "800x600": "http://www.bing.com/az/hprichbg/rb/OregonPainted_ZH-CN8553728911_800x600.jpg",
        "pic": "http://www.bing.com/az/hprichbg/rb/OregonPainted_ZH-CN8553728911_1920x1080.jpg",
        "640x480": "http://www.bing.com/az/hprichbg/rb/OregonPainted_ZH-CN8553728911_640x480.jpg",
        "240x320": "http://www.bing.com/az/hprichbg/rb/OregonPainted_ZH-CN8553728911_240x320.jpg",
        "country": "英國",
        "city": "巴特莱克鑛場遺址",
        "content": "巴特莱克鑛場位於英格蘭西南部,它是英國“錫海岸”的一部分,曾經是一處海底鑛井,地下深處有隧道,鑛工們在這裡可以採集到錫、砷和銅。1895年採鑛被中斷,但懸崖作爲康沃爾郡和西德文郡鑛區的一部分被保護了起來,並成爲教科文組織公認的世界遺産。",
        "title": "俄勒岡州内的“彩繪山丘”,美國 (© David Henderson/plainpicture)",
        "320x240": "http://www.bing.com/az/hprichbg/rb/OregonPainted_ZH-CN8553728911_320x240.jpg",
        "subtitle": "英國,巴特莱克鑛場遺址",
        "1024x768": "http://www.bing.com/az/hprichbg/rb/OregonPainted_ZH-CN8553728911_1024x768.jpg",
        "400x240": "http://www.bing.com/az/hprichbg/rb/OregonPainted_ZH-CN8553728911_400x240.jpg",
        "day": "20170828",
        "1280x768": "http://www.bing.com/az/hprichbg/rb/OregonPainted_ZH-CN8553728911_1280x768.jpg",
        "480x800": "http://www.bing.com/az/hprichbg/rb/OregonPainted_ZH-CN8553728911_480x800.jpg",
        "800x480": "http://www.bing.com/az/hprichbg/rb/OregonPainted_ZH-CN8553728911_800x480.jpg",
        "1366x768": "http://www.bing.com/az/hprichbg/rb/OregonPainted_ZH-CN8553728911_1366x768.jpg"
      },
      {
        "1920*1080": "http://www.bing.com/az/hprichbg/rb/BotallackCornwall_ZH-CN11396172846_1920*1080.jpg",
        "720x1280": "http://www.bing.com/az/hprichbg/rb/BotallackCornwall_ZH-CN11396172846_720x1280.jpg",
        "800x600": "http://www.bing.com/az/hprichbg/rb/BotallackCornwall_ZH-CN11396172846_800x600.jpg",
        "pic": "http://www.bing.com/az/hprichbg/rb/BotallackCornwall_ZH-CN11396172846_1920x1080.jpg",
        "640x480": "http://www.bing.com/az/hprichbg/rb/BotallackCornwall_ZH-CN11396172846_640x480.jpg",
        "240x320": "http://www.bing.com/az/hprichbg/rb/BotallackCornwall_ZH-CN11396172846_240x320.jpg",
        "country": "",
        "city": "",
        "content": "杉葉藻是一種水生植物,它們生長在廣闊的高海拔地域範圍内,從北美的溼地到青藏高原的高海拔地區,這種多年生草本植物棲息在淺水和泥中。杉葉藻還有入葯的效用,在草葯中,杉葉藻有時用來治療傷口。它們的長相也是超級讓人賞心悅目的杉葉形狀。",
        "title": "康沃爾郡内的巴特莱克鑛場, 英國 (© Robert Harding/Masterfile)",
        "320x240": "http://www.bing.com/az/hprichbg/rb/BotallackCornwall_ZH-CN11396172846_320x240.jpg",
        "subtitle": "杉葉藻",
        "1024x768": "http://www.bing.com/az/hprichbg/rb/BotallackCornwall_ZH-CN11396172846_1024x768.jpg",
        "400x240": "http://www.bing.com/az/hprichbg/rb/BotallackCornwall_ZH-CN11396172846_400x240.jpg",
        "day": "20170827",
        "1280x768": "http://www.bing.com/az/hprichbg/rb/BotallackCornwall_ZH-CN11396172846_1280x768.jpg",
        "480x800": "http://www.bing.com/az/hprichbg/rb/BotallackCornwall_ZH-CN11396172846_480x800.jpg",
        "800x480": "http://www.bing.com/az/hprichbg/rb/BotallackCornwall_ZH-CN11396172846_800x480.jpg",
        "1366x768": "http://www.bing.com/az/hprichbg/rb/BotallackCornwall_ZH-CN11396172846_1366x768.jpg"
      }
    ],
    "msg": "提建議加群:2702237"
  }
}


閲完此文,您的感想如何?
  • 有用

    1

  • 沒用

    1

  • 開心

    0

  • 憤怒

    0

  • 可憐

    0

1.如文章侵犯了您的版權,請發郵件通知本站,該文章將在24小時内刪除;
2.本站標注原創的文章,轉發時煩請注明來源;
3.交流群: 2702237 13835667

相關課文
  • mac開發接入微信公衆號接口返回報錯 cURL error 56: SSLRead() return error -9806

  • PHP的換行符是什麽

  • pecl安裝程序時報錯Array and string offset access syntax with curly braces is no longer supported

  • 由於商家傳入的H5交易參數有誤,該筆交易暫時無法完成,請聯繫商家解決

我要說說
網上賓友點評