2013-02-13 65 views
1

FourSquare API文檔指出它支持CORS。然而,向/ users/endpoints調用清楚地表明只支持GET請求:FourSquare API不支持CORS

curl -X OPTIONS -i "https://api.foursquare.com/v2/users/self/checkins?oauth_token=CLIENT_OAUTH_TOKEN" 

HTTP/1.1 405 Method Not Allowed 
Access-Control-Allow-Origin: * 
Cache-Control: no-cache, private, no-store 
Content-Type: application/json; charset=utf-8 
Date: Wed, 13 Feb 2013 04:31:54 GMT 
Expires: Wed, 13 Feb 2013 04:31:54 GMT 
Pragma: no-cache 
Server: nginx/1.2.1 
Tracer-Time: 17 
Content-Length: 104 
Connection: keep-alive 

{"meta":{"code":405,"errorType":"other","errorDetail":"This endpoint only supports GET."},"response":{}} 

這只是特定於這些API端點或者有什麼改變?

回答

0

我還沒有看到FourSquare API中的所有方法,但我的猜測是FourSquare不需要支持預檢請求,因爲他們的所有API請求都很簡單。 docs here建議該API僅支持GET和POST。如果這些請求沒有任何自定義標題,則它們將永遠不需要預檢請求。

+0

感謝Monsur - 但是如果執行XHR GET,瀏覽器會執行此預檢選項請求並失敗。 – 2013-02-13 17:12:11

+0

您可以分享您的預檢請求標題嗎?請求中可能會有一些額外的頭文件(可能會或可能不會)。 – monsur 2013-02-13 18:27:50

+0

這是一個應該工作的客戶端應用程序的示例:http://bl.ocks.org/ajturner/a66ae1a71c43fa7b8a33 – 2013-02-20 16:29:17