2016-10-12 5 views
2

다른 비슷한 이름의 질문으로 내 문제가 해결되지 않았습니다.HTTP 오류 400 잘못된 요청 (비슷한 질문이 나를 도와주지 못함)

왜이 오류가 발생합니까? Google의 github에서이 예제 코드를 복사하여 붙여 넣었습니다.

import pprint 

from googleapiclient.discovery import build 

def main(): 
    # Build a service object for interacting with the API. Visit 
    # the Google APIs Console <http://code.google.com/apis/console> 
    # to get an API key for your own application. 
    service = build("customsearch", "v1", 
     developerKey="AIzaSyDRRpR3GS1F1_jKNNM9HCNd2wJQyPG3oN0") 

    res = service.cse().list(
     q='lectures', 
     cx='017576662512468239146:omuauf_lfve', 
    ).execute() 
    pprint.pprint(res) 

if __name__ == '__main__': 
    main() 

Here is where I go the code from

나는이 오류가 무엇입니까 :

Traceback (most recent call last): 
    File "testpython", line 17, in <module> 
    main() 
    File "testpython", line 12, in main 
    cx='017576662512468239146:omuauf_lfve', 
    File "/home/mddrill/.local/lib/python2.7/site-packages/oauth2client/util.py", line 137, in positional_wrapper 
    return wrapped(*args, **kwargs) 
    File "/home/mddrill/.local/lib/python2.7/site-packages/googleapiclient/http.py", line 838, in execute 
    raise HttpError(resp, content, uri=self.uri) 
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://www.googleapis.com/customsearch/v1?q=lectures&alt=json&cx=017576662512468239146%3Aomuauf_lfve&key=AIzaSyDRRpR3GS1F1_jKNNM9HCNd2wJQyPG3oN0 returned "Bad Request"> 
+0

정말 그 열쇠입니까? –

답변

1

내가 그 bad URL에 액세스하는 시도 것은 이유는 "keyExpired"이라고 말했다.

방문 에 구글 API 콘솔 http://code.google.com/apis/console 자신의 응용 프로그램에 대한 API 키를 얻을 : 또한 여기에 넣어 코드는 다음 설명서가 포함되어 있습니다.

행운을 빕니다!