firebaseアカウント(「child_added」)にデータが追加されるたびに、私が警告を受ける方法としてtwilioを使用しようとしています。私はnode.jsを使用しており、インストールして、コンピュータ上でtwilioを得るためのすべての指示に従っています。しかし、私は自分のアプリケーションを実行するたびに、私は、次のエラーを取得:TwilioでNode.jsが機能しない?
require.js:1958 GET file:///Users/KV/CS/ErrandBoi2/twilio.js net::ERR_FILE_NOT_FOUNDreq.load @ require.js:1958load @ require.js:1682load @ require.js:832fetch @ require.js:822check @ require.js:854enable @ require.js:1173enable @ require.js:1554(anonymous function) @ require.js:1158(anonymous function) @ require.js:134each @ require.js:59enable @ require.js:1110init @ require.js:786(anonymous function) @ require.js:1457
require.js:168 Uncaught Error: Script error for "twilio"
http://requirejs.org/docs/errors.html#scripterror
言い換えれば、私のコンピュータは、私はちょうど私のnode_modulesであるべきと考えていtwilio.jsファイルを、見つけることができません。私のコードを添付して、私が何かを間違ってやっているかどうか知らせてください。私はtwilioに関する行を忠告しているので、submitボタンが押されると、 "thanks.html"に行くフォームアクションもうまくいきません。
私は「twilio.js」ファイルのどこにでも見てきたが、ノードの命令はちょうどNPMを通じてモジュールをダウンロードするために教えてください。私は基本的に私は、これはちょうどあなたがTwilio休憩をインスタンス化する方法で行う必要があると思う
// Creates a variable called databaseLink that links to our database.
var databaseLink = new Firebase('https://errandboi-f1cf5.firebaseio.com/');
// Create javascript variables that link our previous HTML IDs. Remember, we can't use regular HTML inside a script tag, so we need to use JQuery to reference any previous HTML. A $ means we are using JQuery
var messageField = document.getElementById('task');
var nameField = document.getElementById('name');
var contactField = document.getElementById('contact');
var locationField = document.getElementById('location');
var miscField = document.getElementById('misc');
var messageList = $('#example-messages'); // DELETE MAYBE?????
// Twilio Credentials
var accountSid = '[MY_ACCOUNT_SID]';
var authToken = '[MY_AUTH_TOKEN]';
//require the Twilio module and create a REST client
function push() {
databaseLink.push({
name:document.getElementById('name').value,
task:document.getElementById('task').value,
contact:document.getElementById('contact').value,
location:document.getElementById('location').value,
misc:document.getElementById('misc').value,
})
require(['twilio'],function(twilio){
var client = twilio(accountSid, authToken);
ref.on("child_added", function(snapshot, prevChildKey) {
var newPost = snapshot.val();
client.sms.messages.create({ // if "messages.create" doesnt work, try "sendMessage" or "sms.messages.create"
to:'+13177302557',
from:'+13173644864',
body:'You got a new request: \n' + newPost.name + '\n' + newPost.task + '\n' + newPost.contact + '\n' + newPost.location + '\n' + newPost.misc,
}, function(err, message) {
console.log(message.sid);
});
});
});
};
<DOCTYPE! html>
<html>
<head>
<meta charset="UTF-8">
<!-- Twilio Library imporrted-->
<!-- <script type="text/javascript" src="//media.twiliocdn.com/sdk/js/client/v1.3/twilio.min.js"></script> -->
<!--THIS IS NEEDED TO IMPORT FIREBASE LIBRARIES -->
<script src="https://cdn.firebase.com/js/client/2.4.2/firebase.js"></script>
<!-- THIS IS JUST A NICE LOOKING FONT -->
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<!--THIS IS NEEDED TO IMPORT JQUERY LIBRARIES -->
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js'></script>
<!-- THIS IS TO IMPORT MY JS FILE -->
<script data-main="index" src="require.js"></script>
<!-- <script src="index.js"></script> -->
<link href="style.css" rel="stylesheet" />
<title>Btown Errands</title>
</head>
<body>
<div id="container">
<header>
<h1 class="title">Btown Errands</h1>
</header>
<div id="banner">
<h2>Your Helping Hand in Every Situation</h2>
</div>
<div id="content">
<p class="content">Ever have an emergency while you are in class? Life has got you all tied up but your tasks won't do themselves? Well, you are at the right place for help. Let ErrandBoi take the stress off your shoulders while you can do what really matters. Simply, fill out the form below with any* task that you may need help with and one of our drivers will help you out as soon as possible!</p>
<br><br><br><br><br><br><br><br><br>
<div class="form-style-5">
<form action="index.html">
<fieldset>
<legend><span class="number">1</span> Your Information</legend>
<input type="text" name="field1" id="name" placeholder="Your Name *">
<input type="email" name="field2" id="contact"placeholder="Contact Information (Email, Phone Number, etc.) *">
<input type="location" name="field3" id="location" placeholder="Your Location (i.e. McNutt, Hodge Hall, exact address, etc.)*">
<input type="text" name="field4" id="misc" placeholder="Miscellaneous Information That May Be Important"></textarea>
<label for="job">Urgency:</label>
<select id="job" name="field5">
<optgroup label="Urgency level: just for us to prioritize properly">
<option value="Not Urgent">Low (ETA: Up to an hour)</option>
<option value="reading">Normal (ETA: Up to 45 mins)</option>
<option value="boxing">Critical (ETA: ASAP!)</option>
</optgroup>
</select>
</fieldset>
<fieldset>
<legend><span class="number">2</span>Task that needs completion</legend>
<input type="text" id="task" name="field6" placeholder="Let Us Know How We Can Help!*"></input>
</fieldset>
<input name="submit" type="submit" value="Submit" onClick="push()"/>
</form>
</div>
</div>
</div>
</body>
</html>
これを実行しているOSは何ですか? – Edon
私はこれをGoogle Chromeから試しています –
ウェブサーバーなしでこれを実行しているのはなぜですか? –