0

I was wondering if someone can help me implement the Twilio PHP API. I installed the library using composer and changed everything it said to in the documentation.

However, When I try to run the application I just get a blank page. After doing some commenting, it looks like the issue is with the arrays. When I comment out the arrays it will at least give me an error and there will be something when I check the source code.

Below is the code that I'm using. Any help is greatly appreciated.

<?php
require "vendor/autoload.php";
use Twilio\Rest\Client;

$AccountSid = "MySid";
$AuthToken = "MyToken";
$client = new Client($AccountSid, $AuthToken);
$people = array(
    "Number 1" => "Carlos",
    "Number 2" => "Jon",
    "Number 3" => "Madison"
);
foreach ($people as $number => $name) {
    $sms = $client->account->messages->create(
        $number
        array(
            'from' => 'My Number',
            'body' => " This is a test"
            )
    );
  echo "Sent message to $name";

} ?>

3
  • Now that I think about it, it could be a connection issue. I'm not sure why it wouldn't connect. Commented Oct 21, 2016 at 18:58
  • 1
    What was the error you were getting? Commented Oct 28, 2016 at 18:23
  • Blank page in PHP means there's an error sitting in your logs. Commented Feb 2, 2017 at 18:14

1 Answer 1

1

It looks like you're missing a comma after the first argument of the create method.

foreach ($people as $number => $name) {
    $sms = $client->account->messages->create(
        $number,
        array(
            'from' => 'My Number',
            'body' => " This is a test"
            )
    );
  echo "Sent message to $name";
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.