0
require_once("twilio-php-master/Services/Twilio.php");
$AccountSid = "AccountSid"; 
$AuthToken = "AuthToken";

$client = new Services_Twilio($AccountSid, $AuthToken);
try {
    $message = $client->account->messages->create(array(
        "From" => "+16177492903",
        "To" => "+verified number",
        "Body" => "Test message 2 from Fedrick!"
    ));
} catch (Services_Twilio_RestException $e) {
    echo $e->getMessage();
} catch (TwilioException $e) {
    echo $e->getMessage();
} catch (Exception $e) {
}

If I use $client->account->messages->create() line, I'm getting the following error in console:

NetworkError: 500 Internal Server Error ...

How can I overcome this? What is wrong in my code?

Antti29
  • 2,953
  • 12
  • 34
  • 36
  • That's probably error on your side, you can enable errors by putting this line in first line of your php script. `ini_set('disaply_errors',true);` – shyammakwana.me Nov 03 '17 at 07:27
  • Then add error here. – shyammakwana.me Nov 03 '17 at 07:27
  • Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed Warning: file_get_contents(): Failed to enable crypto in /twilio-php/Services/Twilio/HttpStream.php on line 67 Warning: file_get_contents(https://api.twilio.com/2010-04-01/Accounts/ACc19bfa23f4260eb50e0ccc1f98814443/Messages.json): failed to open stream: operation failed in twilio-php/Services/Twilio/HttpStream.php on line 67 – suganthi devi Nov 03 '17 at 09:11
  • I'm getting these errors – suganthi devi Nov 03 '17 at 09:11
  • Are you using the official Twilio PHP SDK as your syntax seems different to what I would expect? See https://www.twilio.com/docs/libraries/php – Andy Nov 03 '17 at 14:00
  • 2
    Possible duplicate of [Twilio PHP - SSL certificate: self signed certificate in certificate chain](https://stackoverflow.com/questions/29153819/twilio-php-ssl-certificate-self-signed-certificate-in-certificate-chain) – philnash Nov 05 '17 at 23:43

2 Answers2

0

Twilio developer evangelist here.

First up it looks like you are using the old version of the Twilio PHP library. I would start by upgrading to version 5.

Further, you're finding SSL certificate issues. The selected answer to this question should help. Or the discussion in this GitHub issue.

Let me know if this helps at all.

philnash
  • 70,667
  • 10
  • 60
  • 88
0

sudo apt-get install php5-curl

and restart the service by sudo service apache2 restart

After installing this ... My error gets cleared