2016-08-03 95 views
0

這似乎是一個非常簡單直接的問題,但我似乎無法在節點twilio setup API中找到錯誤,並且我感覺不到因爲沒有太多的地方可以找到問題。Twilio節點庫:「客戶端需要帳戶SID和身份驗證令牌」

我設置twilio時收到以下錯誤:

Client requires an Account SID and Auth Token set explicitly or via the TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN environment variables 

我的代碼:

var accountSid = 'SID'; 
    var authToken = 'Auth Token'; 
    var client = require('twilio')(accountSid)(authToken); 

    client.messages.create({ 
    to: '+1xxxxxxx', 
    from: '+1xxxxxxx', 
    body: 'Hey, just wanted to remind you about something' 
    }, function (err, response) { 
    console.log('response from twilio is ', response); 
    }); 

我也試圖把字符串,而不是直接使用變量,並收到相同錯誤。我真的在這裏錯過了什麼嗎?這似乎應該工作。

謝謝!

回答

2

更改此:

var client = require('twilio')(accountSid)(authToken); 

這樣:

var client = require('twilio')(accountSid, authToken); 
相關問題