Last active
January 4, 2016 21:49
-
-
Save b-abctech/8683867 to your computer and use it in GitHub Desktop.
Bing search php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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