Nonetype object has no attribute '__getitem__'
<p>I am trying to use an API wrapper downloaded from the net to get results from the new azure Bing API. I'm trying to implement it as per the instructions but getting the runtime error:</p>

<pre><code>Traceback (most recent call last):
  File "bingwrapper.py", line 4, in &lt;module&gt;
    bingsearch.request("affirmative action")
  File "/usr/local/lib/python2.7/dist-packages/bingsearch-0.1-py2.7.egg/bingsearch.py", line 8, in request
    return r.json['d']['results']
TypeError: 'NoneType' object has no attribute '__getitem__'
</code></pre>

<p>This is the wrapper code:</p>

<pre><code>import requests

URL = 'https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/Web?Query=%(query)s&amp;$top=50&amp;$format=json'
API_KEY = 'SECRET_API_KEY'

def request(query, **params):
    r = requests.get(URL % {'query': query}, auth=('', API_KEY))
    return r.json['d']['results']
</code></pre>

<p>The instructions are:</p>

<pre><code>&gt;&gt;&gt; import bingsearch
&gt;&gt;&gt; bingsearch.API_KEY='Your-Api-Key-Here'
&gt;&gt;&gt; r = bingsearch.request("Python Software Foundation")
&gt;&gt;&gt; r.status_code
200
&gt;&gt;&gt; r[0]['Description']
u'Python Software Foundation Home Page. The mission of the Python Software Foundation is to promote, protect, and advance the Python programming language, and to ...'
&gt;&gt;&gt; r[0]['Url']
u'http://www.python.org/psf/
</code></pre>

<p>This is my code that uses the wrapper (as per the instructions):</p>

<pre><code>import bingsearch
bingsearch.API_KEY='abcdefghijklmnopqrstuv'
r = bingsearch.request("affirmative+action")
</code></pre>
