我的控制器
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class MessageController extends Controller
{
public function manyMessage(Request $request){
$message = $request->input("message");
$mobile = $request->input("mobile");
$encodeMessage = urlencode($message);
$authKey = 'BHu2TCgKYAymjrc5iX6ge1NyjePaK1vrrz2e0LbKhTbm3qCIuALM73Fonq0F4EaKvc5zKT7T2PglcjH8DDuB2rhiPL7WXPVr7aDu';
$senderId = 'followupvisitatrion';
$route = 4;
$postData = $request->all();
$mobileNumber = implode('',$postData['mobile']);
$arr = str_split($mobileNumber,11);
$mobiles = implode(",",$arr);
$data = array(
'authKey' => $authKey,
'mobiles' => $mobiles,
'message' => $encodeMessage,
'sender' => $senderId,
'route' => $route,
);
$url = "https://api.infobip.com";
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER =>true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postData,
));
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);
$output = curl_exec($ch);
if(curl_errno($ch)){
echo 'error :'. curl_error($ch);
}
curl_close($ch);
Session::flash('success', 'Message sent Successfully!');
return redirect("/records");
}
}
我的观点
<form role="form" action="{{url("/sendMessage")}}" method="post">
{{csrf_field()}}
<textarea type="hidden" class="form-control" row="4">Write Text</textarea><br>
<input type="submit" class="pull-left btn btn-primary btn-small" value="Send"/><br /><br />
<input type="checkbox" id="select_all" name="select_all"/> Select All<br/><br />
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
New Converts / First Timer
</div>
<!-- /.panel-heading -->
<div class="panel-body">
<div class="dataTable_wrapper">
<table class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Phone Number</th>
<th>Home Address</th>
<th>Email Address</th>
<th>Date</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@if(isset($record))
@foreach($record as $record)
<tr class="odd gradeX">
<td><input type="checkbox" class="checkbox" name="mobile[]" value="{{$record->phone}}"></td>
<td>{{$record->first_name}} - {{$record->last_name}}</td>
<td>{{$record->phone}}</td>
<td>{{$record->home_address}}</td>
<td>{{$record->email}}</td>
<td>{{ Carbon\Carbon::parse($record->created_at)->format('d-m-Y H:i:s') }}</td>
<td><div class="">
<a href="{{URL::to('/editNewConvert')}}/{{$record->id}}" class="btn btn-primary btn-xs">Edit</a>
<a href="{{URL::to('/deleteNewConvert')}}/{{$record->id}}" class="btn btn-danger btn-xs">Delete</a>
</div></td>
</tr>
@endforeach
@endif
</tbody>
</table>
</div>
</form>
错误
(1/1) ErrorException
Array to string conversion
in MessageController.php (line 37)
at HandleExceptions->handleError(8, 'Array to string conversion', 'C:\\xampp\\htdocs\\blog\\app\\Http\\Controllers\\MessageController.php', 37, array('request' => object(Request), 'message' => null, 'mobile' => array('08028479963'), 'encodeMessage' => '', 'authKey' => 'BHu2TCgKYAymjrc5iX6ge1NyjePaK1vrrz2e0LbKhTbm3qCIuALM73Fonq0F4EaKvc5zKT7T2PglcjH8DDuB2rhiPL7WXPVr7aDu', 'senderId' => 'followupvisitatrion', 'route' => 4, 'postData' => array('_token' => 'p7Cg8f0nQzCjwuuVz83WmQngvp7zeiGnQRQS8FPi', 'dataTables-example_length' => '10', 'mobile' => 'Array'), 'mobileNumber' => '08028479963', 'arr' => array('08028479963'), 'mobiles' => '08028479963', 'data' => array('authKey' => 'BHu2TCgKYAymjrc5iX6ge1NyjePaK1vrrz2e0LbKhTbm3qCIuALM73Fonq0F4EaKvc5zKT7T2PglcjH8DDuB2rhiPL7WXPVr7aDu', 'mobiles' => '08028479963', 'message' => '', 'sender' => 'followupvisitatrion', 'route' => 4), 'url' => 'https://api.infobip.com', 'ch' => resource))
at curl_setopt_array(resource, array('https://api.infobip.com', 1, 1, array('_token' => 'p7Cg8f0nQzCjwuuVz83WmQngvp7zeiGnQRQS8FPi', 'dataTables-example_length' => '10', 'mobile' => 'Array')))
in MessageController.php (line 37)