Суть вот в чём, беру готовую библиотеку с smsgateway.me на php
но php ругается
Parse error: syntax error, unexpected '[' in /var/www/html/sms_sync/smsGateway.php on line 14
вот код:
smsGateway.php
<?php
class SmsGateway {
static $baseUrl = "https://smsgateway.me";
function __construct($email,$password) {
$this->email = $email;
$this->password = $password;
}
function createContact ($name,$number) {
<b> return $this->makeRequest('/api/v3/contacts/create','POST',['name' => $name, 'number' => $number]);</b>
}
function getContacts ($page=1) {
return $this->makeRequest('/api/v3/contacts','GET',['page' => $page]);
}
function getContact ($id) {
return $this->makeRequest('/api/v3/contacts/view/'.$id,'GET');
}
function getDevices ($page=1)
{
return $this->makeRequest('/api/v3/devices','GET',['page' => $page]);
}
function getDevice ($id)
{
return $this->makeRequest('/api/v3/devices/view/'.$id,'GET');
}
function getMessages($page=1)
{
return $this->makeRequest('/api/v3/messages','GET',['page' => $page]);
}
function getMessage($id)
{
return $this->makeRequest('/api/v3/messages/view/'.$id,'GET');
}
function sendMessageToNumber($to, $message, $device, $options=[]) {
$query = array_merge(['number'=>$to, 'message'=>$message, 'device' => $device], $options);
return $this->makeRequest('/api/v3/messages/send','POST',$query);
}
function sendMessageToManyNumbers ($to, $message, $device, $options=[]) {
$query = array_merge(['number'=>$to, 'message'=>$message, 'device' => $device], $options);
return $this->makeRequest('/api/v3/messages/send','POST', $query);
}
function sendMessageToContact ($to, $message, $device, $options=[]) {
$query = array_merge(['contact'=>$to, 'message'=>$message, 'device' => $device], $options);
return $this->makeRequest('/api/v3/messages/send','POST', $query);
}
function sendMessageToManyContacts ($to, $message, $device, $options=[]) {
$query = array_merge(['contact'=>$to, 'message'=>$message, 'device' => $device], $options);
return $this->makeRequest('/api/v3/messages/send','POST', $query);
}
function sendManyMessages ($data) {
$query['data'] = $data;
return $this->makeRequest('/api/v3/messages/send','POST', $query);
}
private function makeRequest ($url, $method, $fields=[]) {
$fields['email'] = $this->email;
$fields['password'] = $this->password;
$url = smsGateway::$baseUrl.$url;
$fieldsString = http_build_query($fields);
$ch = curl_init();
if($method == 'POST')
{
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fieldsString);
}
else
{
$url .= '?'.$fieldsString;
}
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HEADER , false); // we want headers
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec ($ch);
$return['response'] = json_decode($result,true);
if($return['response'] == false)
$return['response'] = $result;
$return['status'] = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close ($ch);
return $return;
}
}
?>
index.php
<?php
include "smsGateway.php";
$smsGateway = new SmsGateway('qweqwe@yandex.ru', '11111111');
$deviceID = 1;
$number = 'XXXXXXXXXXX';
$message = 'hello';
$result = $smsGateway->sendMessageToNumber($number, $message, $deviceID);
?>
но штука в том что заливаю данный код на хостинг и там ошибку не выдаёт и всё работает, может надо что то подправить в php.ini??
я так понял он ругаетс на всё где такая структура:
['name' => $name, 'number' => $number]