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 encodedSignature についても同じです: oauthSignature.generate('POST', URL, parameters, consumerSecret),
また、oauth_signature と oauth_nonce を正しく作成しています。