コード例 #1
0
 public function testCheckInbox()
 {
     $response = $this->client->checkInbox(0);
     $this->assertInstanceOf(Inbox::class, $response);
     $response = $response->getMessages();
     $this->assertTrue(is_array($response));
     $this->assertLessThanOrEqual(Inbox::PAGE_LIMIT, count($response));
     foreach ($response as $sms) {
         $this->assertInstanceOf(IncomingSMS::class, $sms);
     }
 }
コード例 #2
0
 public function testSendInvalidSMS()
 {
     $client = new HttpClient(new ConnectionConfig(getenv('OPILO_URL')), new Account(getenv('OPILO_USERNAME'), getenv('OPILO_PASSWORD')));
     $messages = [new OutgoingSMS('abcd', getenv('DESTINATION'), 'invalid from'), new OutgoingSMS(getenv('PANEL_LINE'), 'abcd', 'invalid to'), new OutgoingSMS('3000', getenv('DESTINATION'), 'unauthorized from'), new OutgoingSMS(getenv('PANEL_LINE'), getenv('DESTINATION'), 'authorized from')];
     $response = $client->sendSMS($messages);
     $this->assertCount(4, $response);
     $this->assertInstanceOf(SendError::class, $response[0]);
     $this->assertInstanceOf(SendError::class, $response[1]);
     $this->assertInstanceOf(SendError::class, $response[2]);
     $this->assertInstanceOf(SMSId::class, $response[3]);
     $this->assertSame(SendError::ERROR_RESOURCE_NOT_FOUND, $response[0]->getError());
     $this->assertSame(SendError::ERROR_INVALID_DESTINATION, $response[1]->getError());
     $this->assertSame(SendError::ERROR_RESOURCE_NOT_FOUND, $response[2]->getError());
 }
コード例 #3
0
ファイル: HttpClientTest.php プロジェクト: opilo/webservice
 /**
  * @expectedException \OpiloClient\Response\CommunicationException
  */
 public function testGetCreditWithError()
 {
     // Mock a Guzzle client to be used
     $responseArray = ['error' => 8];
     $responses = [new Response(401, [], json_encode($responseArray))];
     $client = $this->mockGuzzleClient($responses);
     // Make HttpClient to use mocked Guzzle client
     $httpClient = new HttpClient('no-need-for-username', 'no-need-for-password', $client);
     // Call getCredit
     $httpClient->getCredit();
 }
コード例 #4
0
ファイル: index.php プロジェクト: halaei/webservice-bin
<?php

use OpiloClient\Configs\Account;
use OpiloClient\Configs\ConnectionConfig;
use OpiloClient\V2\HttpClient;
use OpiloClient\Request\OutgoingSMS;
require_once __DIR__ . '/webservice-bin.phar';
$config = new ConnectionConfig('http://bpanel.opilo.com');
$account = new Account('YOUR_WEBSERVICE_USERNAME', 'YOUR_WEBSERVICE_PASSWORD');
$client = new HttpClient($config, $account);
$message = new OutgoingSMS('3000****', '0912*******', 'Hello World!');
$responses = $client->sendSMS($message);
echo "Hello World SMS sent!\n";