Javascript ReferenceError:Ember.js中未定义参数
在下一行,我得到了ReferenceError:参数并没有定义,对于ConsumerCret也是一样的 encodedSignature:oauthSignature.generate('POST',URL,参数,ConsumerCret)Javascript ReferenceError:Ember.js中未定义参数,javascript,ember.js,ember-simple-auth,Javascript,Ember.js,Ember Simple Auth,在下一行,我得到了ReferenceError:参数并没有定义,对于ConsumerCret也是一样的 encodedSignature:oauthSignature.generate('POST',URL,参数,ConsumerCret) 此外,我还正确创建了oauth\u签名和oauth\u nonce。好吧,参数和消费者信任在您的代码中没有设置,真的:您正在创建的对象有属性名,未声明变量。看起来encodedSignature可以很好地实现为计算属性: App.StaticConfig =
此外,我还正确创建了oauth\u签名和oauth\u nonce。好吧,
参数和消费者信任在您的代码中没有设置,真的:您正在创建的对象有属性名,未声明变量。看起来encodedSignature
可以很好地实现为计算属性:
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);
});
});
},
}
});
当我在TwitterController中声明变量时,会出现错误“SyntaxError:missing:after property id”。
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')