gpt4 book ai didi

javascript - 引用错误: parameters is not defined in Ember. js

转载 作者:行者123 更新时间:2023-12-03 11:43:58 26 4
gpt4 key购买 nike

App.StaticConfig = Ember.Object.extend({
URL: null,
parameters: null,
consumerSecret: null,
encodedSignature: null,
callback: null,
});


var staticConfig = App.StaticConfig.create({
URL: 'https://api.twitter.com/oauth/request_token',
parameters: {
oauth_consumer_key : 'key',
oauth_nonce : 'kllo9940pd9333jh',
oauth_timestamp : '1191242096',
oauth_signature_method : 'HMAC-SHA1',
oauth_version : '1.0',
},

consumerSecret : 'key',
encodedSignature : oauthSignature.generate('POST', URL, parameters, consumerSecret),

});

App.TwitterController = Ember.ObjectController.extend({

actions: {

loginTwitter: function() {
console.log('Event Clicked');
return new Ember.RSVP.Promise(function(resolve, reject) {
Ember.$.ajax({
url: 'https://api.twitter.com/oauth/request_token',
type: 'POST',
contentType: "jsonp",
headers: {
"Authorization": 'OAuth oauth_callback='+ staticConfig.get('callback') +', oauth_consumer_key="", oauth_nonce="kllo9940pd9333jh", oauth_signature='+ staticConfig.get('encodedSignature') +', oauth_signature_method="HMAC-SHA1", oauth_timestamp="1191242096", oauth_version="1.0"'
},

contentType: 'application/x-www-form-urlencoded'
}).then(function(response) {
console.log('Successed');
console.log(response);
resolve (response);
}, function(xhr, status, error) {
console.log(error);
console.log('In Error');
reject(error);
});
});
},
}
});

在下面的行中,我得到 ReferenceError:parameters is not Defined 并且consumerSecret 也相同编码签名:oauthSignature.generate('POST',URL,参数,consumerSecret),

我也正确创建了 oauth_signature 和 oauth_nonce。

最佳答案

看起来encodedSignature可以很好地实现为计算属性:

encodedSignature : function () {
var URL = this.get('URL');
var parameters = this.get('parameters');
var consumerSecret = this.get('consumerSecret');

return oauthSignature.generate('POST', URL, parameters, consumerSecret)
}.property('URL', 'parameters', 'consumer_secret')

关于javascript - 引用错误: parameters is not defined in Ember. js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26140787/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com