【Authentication and Authorization with Yahoo】- Authorization with OAuth
用到最後!! 覺得 Yahoo 的 API 好像滿多問題的內!! 跟 Google Apis 比較起來!! Google 的文件寫的清楚多了
當然!! 一開始一定要有 Yahoo 的帳號嘍!!
應用程式頁: https://developer.apps.yahoo.com/projects
建立 API Key: https://developer.apps.yahoo.com/dashboard/createKey.html
當在認証 Domain 時,我想很多人都遇到了
Domain Verification Failed
There was an internal error while an application is being created. Please try agin.
有許多人也卡關在這邊,紛紛放棄了 OAuth 而選 BBauth。
也有人提到要更換「地區網站和語言」(Regional Site and Language) 換成 「Yahoo!US in English」
但我後來發現,實際上並不完全是 Yahoo 的問題。 而是 Domain 所存放的 Server (虛擬主機的問題)
就以我自己本身是用智邦生活館的空間,實際上智邦的虛擬主機設定比較嚴謹一些,但我好像用自己測試的機器也是如此。
所以我自已在猜也許是 Apache 的 mod_security 預設就是如此,但不管是誰的問題。
讓 Yahoo 認証通過,就將 SecFilterEngine 設上 Off 就可以了。
若是購買虛擬主機的人,可以加一個 .htaccess 的檔案
內容:
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
這樣就可以解決了!!
補充資訊: 提供一下 error log 讓大家了解一下嘍!!
在 Apache 的 Logs
error_log
[Wed Apr 13 16:33:03 2011] [error] [client 98.136.43.14] mod_security: Access denied with code 500. Pattern match "^$" at HEADER("User-Agent") [severity "EMERGENCY"] [hostname "********"] [uri "/Pmsp7T9WchkLg9U7ss8KIA--.html?r=840427608"]
audit_log
==96536e3d==============================
Request: ******** 98.136.43.14 - - [13/Apr/2011:16:33:03 +0800] "GET /Pmsp7T9WchkLg9U7ss8KIA--.html?r=840427608 HTTP/1.1" 500 544 "-" "-" - "-"
----------------------------------------
GET /Pmsp7T9WchkLg9U7ss8KIA--.html?r=840427608 HTTP/1.1
Host: ********
Accept: */*
mod_security-message: Access denied with code 500. Pattern match "^$" at HEADER("User-Agent") [severity "EMERGENCY"]
mod_security-action: 500
HTTP/1.1 500 Internal Server Error
Content-Length: 544
Connection: close
Content-Type: text/html; charset=iso-8859-1
--96536e3d--
申請完 Yahoo API 後,由於小弟是寫 PHP 的
所以下載完 Sdk-PHP 就可正常的使用 Yahoo OAuth 嘍!!
SDk-PHP 來源: http://developer.yahoo.com/social/sdk/php/
Yahoo 文件來源: http://developer.yahoo.com/oauth/guide/oauth-auth-flow.html