Skip to content

Instantly share code, notes, and snippets.

@b-abctech
Last active January 4, 2016 21:49
Show Gist options
  • Save b-abctech/8683867 to your computer and use it in GitHub Desktop.
Save b-abctech/8683867 to your computer and use it in GitHub Desktop.
Bing search php
<?php
/****
* PHP proxy for using the Bing Search API with AJAX
*/
$acctKey = 'xxx';
$requestUri = "$rootUri/Web?\$format=json&Query=xbox&Market=en-US";
// Encode the credentials and create the stream context.
$auth = base64_encode("$acctKey:$acctKey");
$data = array(
'http' => array(
'request_fulluri' => true,
// ignore_errors can help debug – remove for production. This option added in PHP 5.2.10
'ignore_errors' => true,
'header' => "Authorization: Basic $auth")
);
$context = stream_context_create($data);
// Get the response from Bing.
$response = file_get_contents($requestUri, 0, $context);
// Send the response back to the browser.
echo $response;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment