Note that there are some explanatory texts on larger screens.

plurals
  1. PONew Bing API PHP example doesnt work
    primarykey
    data
    text
    <p>Microsoft's own PHP example for new Bing API doesn't work. I tried in many ways, it just shows:</p> <blockquote> <p>Server Error<br> 401 - Unauthorized: Access is denied due to invalid credentials.<br> You do not have permission to view this directory or page using the credentials that you supplied.</p> </blockquote> <p>Example Coding given in the official documentation is below, it breaks up at </p> <pre><code>'proxy' =&gt; 'tcp://127.0.0.1:8888', </code></pre> <p>I am 100% sure my key is correct, and when I just enter it in the browser url it works fine, i.e </p> <pre><code>https://api.datamarket.azure.com/Bing/SearchWeb/Web?Query=%27love+message%27 </code></pre> <p>(you need to put the API key as your password and username can be anything)</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;link href="styles.css" rel="stylesheet" type="text/css" /&gt; &lt;title&gt;PHP Bing&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form method="post" action="&lt;?php echo $_SERVER['PHP_SELF'];?&gt;"&gt; Type in a search: &lt;input type="text" id="searchText" name="searchText" value="&lt;?php if (isset($_POST['searchText'])) { echo($_POST['searchText']); } else { echo('sushi'); } ?&gt;" /&gt; &lt;input type="submit" value="Search!" name="submit" id="searchButton" /&gt; &lt;?php if (isset($_POST['submit'])) { // Replace this value with your account key $accountKey = 'BKqC2hIKr8foem2E1qiRvB5ttBQJK8objH8kZE/WJVs='; $ServiceRootURL = 'https://api.datamarket.azure.com/Bing/Search/'; $WebSearchURL = $ServiceRootURL . 'Image?$format=json&amp;Query='; $context = stream_context_create(array( 'http' =&gt; array( //'proxy' =&gt; 'tcp://127.0.0.1:8888', 'request_fulluri' =&gt; true, 'header' =&gt; "Authorization: Basic " . base64_encode($accountKey . ":" . $accountKey) ) )); $request = $WebSearchURL . urlencode( '\'' . $_POST["searchText"] . '\''); echo($request); $response = file_get_contents($request, 0, $context); print_r($response); $jsonobj = json_decode($response); echo('&lt;ul ID="resultList"&gt;'); foreach($jsonobj-&gt;d-&gt;results as $value) { echo('&lt;li class="resultlistitem"&gt;&lt;a href="' . $value-&gt;MediaURL . '"&gt;'); echo('&lt;img src="' . $value-&gt;Thumbnail-&gt;MediaUrl. '"&gt;&lt;/li&gt;'); } echo("&lt;/ul&gt;"); } ?&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I have tried both google API and Yahoo API both, none of those were as difficult as this.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload