bugfix> php > 投稿

私はこれに関する指示に従ったウェブサイト sendnotifications.phpファイルにエラーがあります。送信確認を受信せず、「メッセージが送信されました」および「メッセージが送信されていません」というメッセージが画面に表示されません。



// Required if your environment does not handle autoloading
require __DIR__ . '/Twilio/autoload.php';
// Use the REST API Client to make requests to the Twilio REST API
use Twilio\Rest\Client;
// Your Account SID and Auth Token from twilio.com/console
$sid = ‘MyAccountSID’;
$token = ‘MyToken’;
$client = new Client($sid, $token);
// Use the client to do fun stuff like send text messages!
    // the number you'd like to send the message to
        // A Twilio phone number you purchased at twilio.com/console
        'from' => ‘MyTwilioNumber’,
        // the body of the text message you'd like to send
        'body' => « MyMessage »
// Display a confirmation message on the screen
$sms_check=’OK’; //Use Twilio’s callback here
$return_json = ‘{"sms_sent":"’ . $email_check . ‘"}’;
echo $return_json;


<!doctype html>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript">// <![CDATA[///////////Javascript
    $.post("sendnotifications.php", $("#frm").serialize(),
    if(data.sms_sent == 'OK'){
    alert("Message Sent");
    } else {
    alert("Message Not Sent");
    }, "json");
    // ]]>
<form id="frm" name="frm">
<input type="hidden" name="ajax" value="1" />
<input type="phone" name="phone" />
<button type="submit">Get Link</button>
<div class="error" style="display: none;"></div>

Visual Studio Codeのエラー:

    "resource": "/Users/Joris/Desktop/Test envoi sms accueil/sendnotifications.php",
    "owner": "_generated_diagnostic_collection_name_#0",
    "code": "undefined",
    "severity": 8,
    "message": "syntax error, unexpected '{'",
    "startLineNumber": 31,
    "startColumn": 1,
    "endLineNumber": 31,
    "endColumn": 1.7976931348623157e+308


Uncaught TypeError: Cannot read property 'sms_sent' of null
    at Object.success (source.html:10)
    at b (jquery.min.js:124)
    at XMLHttpRequest.x.onreadystatechange (jquery.min.js:129)
(anonymous) @ source.html:10
b @ jquery.min.js:124
x.onreadystatechange @ jquery.min.js:129
XMLHttpRequest.send (async)
ajax @ jquery.min.js:130
post @ jquery.min.js:122
(anonymous) @ source.html:8
handle @ jquery.min.js:55
o @ jquery.min.js:49