telekommander / bingdailyphoto
BingPhoto是一个简单的PHP类,用于获取Bing每日图片及其元数据。
1.0.0
2017-09-01 13:45 UTC
Requires
- php: >=5.6
This package is not auto-updated.
Last update: 2024-09-23 07:39:28 UTC
README
BingPhoto是一个简单的PHP类,用于获取Bing每日图片及其元数据。
基本用法
$bing = new BingPhoto(); $image = $bing->getImage(); // Example result ($image) [ [startdate] => '20160913' [fullstartdate] => '201609130700' [enddate] => '20160914' [url] => 'http://www.bing.com/az/hprichbg/rb/Meteora_EN-US6763889417_1920x1080.jpg' [urlbase] => '/az/hprichbg/rb/Meteora_EN-US6763889417' [copyright] => 'Roussanou and other monasteries in Metéora, Greece (© Stian Rekdal/Nimia)' // ... ]
参数
该类有一些可选参数,用于控制各种选项
示例
// Fetches two images of the day in high resolution from the American Bing portal // Composer autoloader first require __DIR__ . "/vendor/autoload.php"; // Here we go use BingPhoto\BingPhoto; $bing = new BingPhoto(BingPhoto::YESTERDAY, 2); $images = $bing->getImages();
// Fetches three images of the day in low resolution, starting yesterday from the French Bing portal // Composer autoloader first require __DIR__ . "/vendor/autoload.php"; // Here we go use BingPhoto\BingPhoto; $bing = new BingPhoto(BingPhoto::YESTERDAY, 3, 'fr-FR', BingPhoto::RESOLUTION_LOW); foreach ($bing->getImages() as $image) { printf('<img src="%s">', $image['url']); }
// Output the image of the day as an image in high resolution // Composer autoloader first require __DIR__ . "/vendor/autoload.php"; // Here we go use BingPhoto\BingPhoto; $bing = new BingPhoto(BingPhoto::TODAY, 1, 'de-DE', BingPhoto::RESOLUTION_HIGH); $current = $bing->getImage(); $info = getimagesize($current['url']); header("Content-type: " . $info["mime"]); readfile($current['url']); die();