PHP 使用 Bing API
PHP 使用 Bing API 首先你要去申请一个 Bing API KEY
申请地址: http://cn.bing.com/developers/
使用方法:
<?php
// Include the Bing API PHP Library
require 'library/BingAPI.php';
// Simply start the class with your AppID argumented
$search = new BingAPI('YOUR APPID KEY');
$search->query($searchWeb)
->setSources('Web') # To use multiple resources simply do ->setSources('Web+Image') , it must match the source type bling.com provides
->setFormat('xml')
->setOptions(array(
'Web.Count' => '20',
'Web.Offset' => '0',
'Adult' => 'Moderate',
'Options' => 'EnableHighlighting'));
// Contains the search
$results = $search->getResults();
/* To use highlighting features use
/* $search->setHighlightFormat(
&<span class='hl'>&,
&</span>&,
$SOURCE_TO_FORMAT
);
*/
/* If you don't want to highlight your title use
$search->resetHighlight($string_containing_bing's title);
*/
/* For advanced cURL Users, setProxy() has been removed, you will utilize $search->setCurlArray(array()); */
/* And for developers who constantly lurks in bing forums or other developer forums there is $search->getRequestedQueryURL(); it will retrieve the link you use
to query bing.com servers. eg. http://api.search.live.net/xml.aspx?AppId=YOUR APPD ID&Query=da&Sources=Image&Image.Count=20&Image.Offset=0&Image.Filters=Size:Small&Adult=Moderate&Options=EnableHighlighting
Note that it will return THE CURRENT URL.
*/
下载: BingAPI.php
关键字:PHP Bing API
新文章:
- CentOS7下图形配置网络的方法
- CentOS 7如何添加删除用户
- 如何解决centos7双系统后丢失windows启动项
- CentOS单网卡如何批量添加不同IP段
- CentOS下iconv命令的介绍
- Centos7 SSH密钥登陆及密码密钥双重验证详解
- CentOS 7.1添加删除用户的方法
- CentOS查找/扫描局域网打印机IP讲解
- CentOS7使用hostapd实现无AP模式的详解
- su命令不能切换root的解决方法
- 解决VMware下CentOS7网络重启出错
- 解决Centos7双系统后丢失windows启动项
- CentOS下如何避免文件覆盖
- CentOS7和CentOS6系统有什么不同呢
- Centos 6.6默认iptable规则详解