php - HTTP ERROR 500 - SMSGteway.me -
this question has answer here:
- php parse/syntax errors; , how solve them? 11 answers
i using code below verification purposes.
login.php:
include "smsgateway.php"; $smsgateway = new smsgateway('someone@mysite.com', 'password'); $did = 98751; $numb = '30xxxxx'; date_default_timezone_set('asia/karachi'); $dated = date('d-m-y h:i a', time()); $msg = "fraudlent activity detected on prescription data website on ".$dated." ."; $deviceid = $did; $number = '+92'.$numb; $message = $msg; $result = $smsgateway->sendmessagetonumber($number, $message, $deviceid);
smsgateway.php:
<?php class smsgateway { static $baseurl = "https://smsgateway.me"; function __construct($email,$password) { $this->email = $email; $this->password = $password; } function createcontact ($name,$number) { return $this->makerequest('/api/v3/contacts/create','post',['name' => $name, 'number' => $number]); } 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); // 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; } }
?>
when try login without code works charm. when try login code included, shows http error 500 in browser. error log shows this: php parse error: syntax error, unexpected '[' in /home/xxxx/public_html/xxxx/smsgateway.php on line 18
maybe php version issure. try array('page' => $page)
, insted of ['page' => $page]
Comments
Post a Comment