使用Yelp API时出现OAuth错误
OAuth Error using Yelp API
我有一个示例应用程序,它使用Yelp来检索评论和联系信息。直到本周,它一直运行良好。
我现在收到以下错误:未捕获引用错误:未定义OAuth
function addmarker(lat,lng, id, name, comments){
var yelpcontent = '<h4>' + name + '</h4>';
var phone = '';
var address = '';
var city = '';
var state = '';
var zip = '';
var rating = '';
var terms = name;
var near = 'Indianapolis,IN';
var cll = lat + "," + lng;
var accessor = {
consumerSecret: auth.consumerSecret,
tokenSecret: auth.accessTokenSecret
};
parameters = [];
parameters.push(['term', name]);
parameters.push(['location', 'Indianapolis, IN']);
parameters.push(['cll', cll]);
parameters.push(['callback', 'cb']);
parameters.push(['oauth_consumer_key', auth.consumerKey]);
parameters.push(['oauth_consumer_secret', auth.consumerSecret]);
parameters.push(['oauth_token', auth.accessToken]);
parameters.push(['oauth_signature_method', 'HMAC-SHA1']);
var message = {
'action': 'http://api.yelp.com/v2/search',
'method': 'GET',
'parameters': parameters
};
OAuth.setTimestampAndNonce(message);
OAuth.SignatureMethod.sign(message, accessor);
var parameterMap = OAuth.getParameterMap(message.parameters);
parameterMap.oauth_signature = OAuth.percentEncode(parameterMap.oauth_signature)
$.ajax({
'url': message.action,
'data': parameterMap,
'cache': true,
'dataType': 'jsonp',
'type' : 'get',
'timeout': 5000,
'success': function(data, textStats, XMLHttpRequest) {
address = data['businesses'][0].location.address;
city = data['businesses'][0].location.city;
state = data['businesses'][0].location.state_code;
zip = data['businesses'][0].location.postal_code;
phone = data['businesses'][0].display_phone;
rating = data['businesses'][0].rating_img_url_small;
yelpcontent = yelpcontent + '<p>' + address + '<br/>' + city + ', ' + state + ' ' + zip + '<br/>' + phone + '</p><p><strong>Yelp Rating</strong></p><p><img src=' + rating + '></p><p><strong>Personal Review</strong></p><p>' + comments + '</p>';
},
'error': function(data, textStats, XMLHttpRequest) {
console.log(name + ' ' + 'did not work');
console.log(XMLHttpRequest);
yelpcontent = yelpcontent + '<p>' + comments + '</p>';
}
});
有人能告诉我我做错了什么吗?
OAuth在Javascript中默认情况下没有定义。
你必须将它添加到你的页面中。
使用此代码:
<script type="text/javascript" src="http://oauth.googlecode.com/svn/code/javascript/oauth.js"></script>
<script type="text/javascript" src="http://oauth.googlecode.com/svn/code/javascript/sha1.js"></script>
你可以在这里看到一个完整的例子。
相关文章:
- Node.js v6.2.0类扩展不是函数错误
- Jquery菜单操作不稳定,定位不正确,存在一般错误
- document.open/document.write没有正确地清除chrome中的文档——这是chrome的错误吗
- 试图在引导模式内动态生成图表,得到offsetWidth错误
- 为什么会出现错误;未捕获的类型错误:undefined不是函数;
- 使用Yelp API时出现OAuth错误
- 错误:invalid_client找不到 YouTube 分析应用脚本插件的 OAuth 客户端
- OAuth错误:签名验证失败
- 在尝试SE OAuth初始化时,Firefox插件中出现channelUrl错误
- 使用 OAuth.io JS 库从LinkedIn获取个人源会给出 403 禁止错误
- 收到错误 401 未经授权,无法在 Twitter 中验证 OAuth 签名和令牌
- Meteor.js 帐户-facebook 允许美国 facebook 帐户,但不允许德国 OAuth 错误
- Javascript 类型错误:oauth 不是构造器
- 谷歌oauth卫星404错误
- 使用Javascript的Twitter OAuth Request_Token,可能是错误的时间
- 我一直得到http 403错误为谷歌Oauth 2.0(钛合金)
- Angularjs oauth错误:setRequestHeader'XMLHttpRequest':
- OAuth.使用OAuth获取tweet时出现未定义错误.重定向方法的回调
- OAuth,403在request_token上出现响应错误
- Angularfire2 oauth登录时出现无效凭据错误