public function setTestRecipientIsSuccesful() { $recipient = '49123456789'; $sender = 'easySMS'; $message = 'Hi, this is me'; $instance = new Message($recipient, $sender, $message); $this->assertEquals($recipient, $instance->getTo()); }
/** * Sends a message through the gateway. * * @param Message $message Message * @param bool $debug If debug mode should be enabled * * @return \AndreasWeber\SMS\Core\Response * @throws \RuntimeException */ public function send(Message $message, $debug = false) { // gather arguments $params = array('key' => $this->apiKey, 'to' => $message->getTo(), 'message' => $message->getMessageText(), 'route' => $this->route, 'from' => $message->getFrom(), 'debug' => $debug ? 1 : 0); // build request $query = http_build_query($params, null, '&'); // send request via curl $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, self::URI); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $query); curl_setopt($ch, CURLOPT_USERAGENT, 'easySMS-php'); $responseCode = intval(curl_exec($ch)); curl_close($ch); // prepare response $response = new Response(time(), 100 === $responseCode ? true : false, $responseCode, $this->getResponseMessageToResponseCode($responseCode)); // return response return $response; }
/** * Sends a message through the gateway. * * @param Message $message Message * @param bool $debug If debug mode should be enabled * * @return Response */ public function send(Message $message, $debug = false) { Assertion::boolean($debug); $params = $this->createParamsInstance(); $params->originator = $message->getFrom(); $params->destinations = $message->getTo(); $params->body = $message->getMessageText(); $params->validity = 48; $params->characterSetID = 2; $params->replyMethodID = 4; $this->setOptions($params, $message); if ($debug) { $method = 'TestSendSMS'; } else { $method = 'SendSMS'; } $result = $this->call($method, $params); $meta = $this->extractResponseMetaData($result); $response = new Response(time(), $meta['code'] === 1, $meta['code'], $meta['message']); return $response; }