2013-07-23 38 views
1

這是問題所在,我有一個谷歌瀏覽器擴展,我想在其中使用BOSS API。問題是,我不知道是否有可能在沒有運行Web服務器的情況下使用API​​。只能使用JavaScript的雅虎BOSS OAuth嗎?

該文檔不提供任何使用JavaScript的示例。因此,我的問題:

是否有可能只使用JavaScript雅虎BOSS OAuth?

+0

是否有人回答過這個問題? – beenjaminnn

回答

0

也許不是......

雅虎提供了正在使用的服務器端語言

http://developer.yahoo.com/boss/search/boss_api_guide/codeexamples.html

首先你必須弄清楚如何使用OAuth使用JavaScript,以及如何將所有的例子你會隱藏JS文件中的用戶API密鑰嗎?如果您不必擔心這一點,請說明您只是將其用於個人用途。也許可以查看Node.JS的代碼示例並將其修改爲您自己的用途。

http://developer.yahoo.com/boss/search/boss_api_guide/codeexamples.html#oauth_js

function yahooSearch(consumerKey, consumerSecret, query, count, 
callback_error_data_response){ 
var webSearchUrl = 'https://yboss.yahooapis.com/ysearch/web'; 

    var finalUrl = webSearchUrl + '?' + qs.stringify({ 
    q: query, //search keywords 
    format: 'json', 
    count: count, 
    }); 

    var oa = new OAuth(webSearchUrl, webSearchUrl, consumerKey, consumerSecret, "1.0", null, "HMAC-SHA1"); 
    oa.setClientOptions({ requestTokenHttpMethod: 'GET' }); 
    oa.getProtectedResource(finalUrl, "GET", '','', callback_error_data_response); 
} 

// Use this function to make a call back. Make sure to provide the right key, secret and query for this to work correctly yahooSearch('YAHOO CONSUMER KEY GOES HERE', 'YAHOO CONSUMER SECRET GOES HERE', 'SEARCH QUERY', 10, function(error, data, response){ 
// enter some code here and access the results from the "data" variable in JSON format 
}); 
0

你可以去YQL Console,然後輸入您的要求,您可以選擇JSON或XML,你以後的結果是牽強,看頁面的底部,然後複製網址。您將能夠在HTML文檔的腳本標記中使用該URL,並在沒有服務器的情況下使用瀏覽器運行它。