如何在Laravel中的twilio中发送多个值?

时间:2019-04-21 16:53:59

标签: php laravel twilio

我正在使用公交车预订系统,我需要向用户发送预订详细信息,例如预订日期,预订座位,价格等,这样我该怎么办?

发送按摩的默认代码:

class SmsController extends Controller
{
    public function sendSms()
    {
        $to = '+15778135468';
        $messagess = 'Hello World';
        $accountSid = config('app.twilio')['TWILIO_ACCOUNT_SID'];
        $authToken  = config('app.twilio')['TWILIO_AUTH_TOKEN'];
        $appSid     = config('app.twilio')['TWILIO_APP_SID'];
        $client = new Client($accountSid, $authToken);
        try
        {

            $client->messages->create(

                $to,
           array(

                 'from' => '+15092071880',
                 'body' => $messagess

             )
         );
   }
        catch (Exception $e)
        {
            echo "Error: " . $e->getMessage();
        }
    }
}

我尝试过这样:

class SmsController extends Controller
{
    public function sendSms()
    {
        $to = '+15778135468';
        $messagess =  $schedule->routes_id;
        $messagess1 = $request->buses_id;
        $messagess2 = $request->schedules_id;
        $messagess4 = $request->seat;
        $accountSid = config('app.twilio')['TWILIO_ACCOUNT_SID'];
        $authToken  = config('app.twilio')['TWILIO_AUTH_TOKEN'];
        $appSid     = config('app.twilio')['TWILIO_APP_SID'];
        $client = new Client($accountSid, $authToken);
        try
        {

            $client->messages->create(

                $to,
           array(

                 'from' => '+15092071880',
                 'body' => $messagess,$messagess1,$messagess2,$messagess3,$messagess4

             )
         );
   }
        catch (Exception $e)
        {
            echo "Error: " . $e->getMessage();
        }
    }
}

也这样:

'body' => $messagess,
'body' => $messagess1,
'body' => $messagess2,
'body' => $messagess3,
'body' => $messagess4

预期结果:

路线详细信息美国到英国
巴士详细信息空中巴士
日期ex.2019 / 04/22
A1号座位

但没有用,所以请帮助我找出答案。谢谢

0 个答案:

没有答案