Следующий код не возвращает 50 результатов новостей.Я использую &count=50&offset=0
, но не работает.
Любая помощь приветствуется.
$endpoint = 'https://api.cognitive.microsoft.com/bing/v7.0/news';
$term = $_GET['q'];
$site = '(((site:aaa.com+OR+site:bbb.com)+OR+site:ccc.net)+OR+site:ddd.com)';
function BingNewsSearch ($url, $key, $query, $site) {
$headers = "Ocp-Apim-Subscription-Key: $key\r\n";
$options = array ('http' => array (
'header' => $headers,
'method' => 'GET' ));
// Perform the Web request and get the JSON response
$context = stream_context_create($options);
$result = file_get_contents($url . "?q=" .
urlencode($query).'+'.$site.'&cc=CR&setLang=es&count=50&offset=0', false,
$context);
// Extract Bing HTTP headers
$headers = array();
foreach ($http_response_header as $k => $v) {
$h = explode(":", $v, 2);
if (isset($h[1]))
if (preg_match("/^BingAPIs-/", $h[0]) || preg_match("/^X-MSEdge-/", $h[0]))
$headers[trim($h[0])] = trim($h[1]);
}
return array($headers, $result);
}
print "Searching news for: " . $term . "\n";
list($headers, $json) = BingNewsSearch($endpoint, $accessKey, $term, $site);