├── .editorconfig ├── CHANGELOG.md ├── CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── XREADME.md ├── composer.json └── src ├── AfricasTalkingGateway.php ├── AfricasTalkingLaravel5Facade.php ├── AfricasTalkingLaravel5ServiceProvider.php ├── Http └── routes.php └── config └── config.php /.editorconfig: -------------------------------------------------------------------------------- 1 | ; This file is for unifying the coding style for different editors and IDEs. 2 | ; More information at http://editorconfig.org 3 | 4 | root = true 5 | 6 | [*] 7 | charset = utf-8 8 | indent_size = 4 9 | indent_style = space 10 | end_of_line = lf 11 | insert_final_newline = true 12 | trim_trailing_whitespace = true 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All Notable changes to `:package_name` will be documented in this file. 4 | 5 | Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles. 6 | 7 | ## NEXT - YYYY-MM-DD 8 | 9 | ### Added 10 | - Nothing 11 | 12 | ### Deprecated 13 | - Nothing 14 | 15 | ### Fixed 16 | - Nothing 17 | 18 | ### Removed 19 | - Nothing 20 | 21 | ### Security 22 | - Nothing 23 | -------------------------------------------------------------------------------- /CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. 4 | 5 | We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality. 6 | 7 | Examples of unacceptable behavior by participants include: 8 | 9 | * The use of sexualized language or imagery 10 | * Personal attacks 11 | * Trolling or insulting/derogatory comments 12 | * Public or private harassment 13 | * Publishing other's private information, such as physical or electronic addresses, without explicit permission 14 | * Other unethical or unprofessional conduct. 15 | 16 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team. 17 | 18 | This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community in a direct capacity. Personal views, beliefs and values of individuals do not necessarily reflect those of the organisation or affiliated individuals and organisations. 19 | 20 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. 21 | 22 | This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/) 23 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are **welcome** and will be fully **credited**. 4 | 5 | We accept contributions via Pull Requests on [Github](https://github.com/freddiedfre/AfricasTalkingLaravel5). 6 | 7 | 8 | ## Pull Requests 9 | 10 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer). 11 | 12 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests. 13 | 14 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. 15 | 16 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. 17 | 18 | - **Create feature branches** - Don't ask us to pull from your master branch. 19 | 20 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 21 | 22 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. 23 | 24 | 25 | ## Running Tests 26 | 27 | ``` bash 28 | $ composer test 29 | ``` 30 | 31 | 32 | **Happy coding**! 33 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | 3 | Copyright (c) 2016 :author_name <:author_email> 4 | 5 | > Permission is hereby granted, free of charge, to any person obtaining a copy 6 | > of this software and associated documentation files (the "Software"), to deal 7 | > in the Software without restriction, including without limitation the rights 8 | > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | > copies of the Software, and to permit persons to whom the Software is 10 | > furnished to do so, subject to the following conditions: 11 | > 12 | > The above copyright notice and this permission notice shall be included in 13 | > all copies or substantial portions of the Software. 14 | > 15 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | > THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # This repo has moved 2 | 3 | It now lives in the https://github.com/freddiedfre/at-sms-laravel-integration.git -------------------------------------------------------------------------------- /XREADME.md: -------------------------------------------------------------------------------- 1 | # INSTALLATION AND USAGE GUIDE 2 | 3 | NB. 4 | - This package is a ServiceProvider for aricastalking SMS gateway laravel 5.2. 5 | - You will need a username and API key from https://www.africastalking.com/ 6 | 7 | 8 | ## Installation Steps 9 | 10 | - run the following composer command at the root of your projects. 11 | 12 | 13 | composer require freddiedfre/africas_talking_laravel_5=dev-master 14 | 15 | - Update the config/app.php with the following code. 16 | 17 | 18 | 'providers' => [ 19 | ... 20 | FreddieDfre\AfricasTalkingLaravel5\AfricasTalkingLaravel5ServiceProvider::class, 21 | ] 22 | 23 | 24 | 'aliases' => [ 25 | ... 26 | 'SMSProvider' =>FreddieDfre\AfricasTalkingLaravel5\AfricasTalkingLaravel5Facade::class, 27 | ] 28 | 29 | - run `php artisan vendor:publish` 30 | 31 | - Navigate to config/AfricastalkingGateway.php and fill in your username and api_key 32 | 33 | 34 | 'yourafricastalking username', 37 | 'api_key' => 'Your API Key obtained from AfricasTalking.com', 38 | ]; 39 | 40 | - run `php artisan config:clear` 41 | 42 | - run `composer dump-autoload` 43 | 44 | ## Usage Instructions 45 | 46 | The AfricasTalkingGateway.php methods will now be available via a Facade. 47 | - Text Message Methods 48 | * `SMSProvider::sendMessage($to_, $message_, $from_ = null, $bulkSMSMode_ = 1, Array $options_ = array());` 49 | * `SMSProvider::fetchMessages($lastReceivedId_);` 50 | 51 | - Subscription Services Methods 52 | * `SMSProvider::createSubscription($phoneNumber_, $shortCode_, $keyword_);` 53 | * `SMSProvider::deleteSubscription($phoneNumber_, $shortCode_, $keyword_);` 54 | * `SMSProvider::fetchPremiumSubscriptions($shortCode_, $keyword_, $lastReceivedId_ = 0);` 55 | * `SMSProvider::getNumQueuedCalls($phoneNumber_, $queueName = null);` 56 | 57 | - Call methods 58 | * `SMSProvider::call($from_, $to_);` 59 | * `SMSProvider::getNumQueuedCalls($phoneNumber_, $queueName = null);` 60 | * `SMSProvider::uploadMediaFile($url_);` 61 | 62 | - Airtime method 63 | * `SMSProvider::sendAirtime($recipients);` 64 | 65 | - User info method 66 | * `SMSProvider::getUserData();` 67 | 68 | ## Test Example 69 | 70 | Add the following route to your routes.php and navigate to it on your browser. 71 | 72 | Route::get('test', function () { 73 | SMSProvider::sendMessage('ReplaceWithYouPhoneNumber', 'ReplaceWithYourSampleMessage'); 74 | }); 75 | 76 | 77 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "freddiedfre/africas_talking_laravel_5", 3 | "type": "library", 4 | "description": "A package for integrating Africa's Talking SMS gateway into a Laravel 5 App.", 5 | "keywords": ["africastalking","sms gateway"], 6 | "homepage": "https://github.com/freddiedfre/AfricasTalkingLaravel5", 7 | "license": "MIT", 8 | "authors": [ 9 | { 10 | "name": "Fredrick A", 11 | "email": "fredrickanyera@gmail.com", 12 | "homepage": "https://github.com/freddiedfre", 13 | "role": "Developer" 14 | } 15 | ], 16 | "require": { 17 | "illuminate/support": "~5.1", 18 | "php" : "~5.5|~7.0" 19 | }, 20 | "require-dev": { 21 | "phpunit/phpunit" : "4.*", 22 | "scrutinizer/ocular": "~1.1", 23 | "squizlabs/php_codesniffer": "~2.3" 24 | }, 25 | "autoload": { 26 | "psr-4": { 27 | "FreddieDfre\\AfricasTalkingLaravel5\\": "src" 28 | } 29 | }, 30 | "autoload-dev": { 31 | "psr-4": { 32 | ":vendor\\:package_name\\Test\\": "tests" 33 | } 34 | }, 35 | "scripts": { 36 | "test": "phpunit" 37 | }, 38 | "extra": { 39 | "branch-alias": { 40 | "dev-master": "1.0-dev" 41 | } 42 | }, 43 | "minimum-stability" : "dev" 44 | } 45 | 46 | -------------------------------------------------------------------------------- /src/AfricasTalkingGateway.php: -------------------------------------------------------------------------------- 1 | 5 | 6 | AFRICAStALKING SMS GATEWAY CLASS IS A FREE SOFTWARE IE. CAN BE MODIFIED AND/OR REDISTRIBUTED 7 | UNDER THE TERMS OF GNU GENERAL PUBLIC LICENCES AS PUBLISHED BY THE 8 | FREE SOFTWARE FOUNDATION VERSION 3 OR ANY LATER VERSION 9 | 10 | THE CLASS IS DISTRIBUTED ON 'AS IS' BASIS WITHOUT ANY WARRANTY, INCLUDING BUT NOT LIMITED TO 11 | THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 12 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 13 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 14 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | 16 | */ 17 | namespace FreddieDfre\AfricasTalkingLaravel5; 18 | 19 | class AfricasTalkingGatewayException extends \Exception{} 20 | 21 | class AfricasTalkingGateway 22 | { 23 | protected $_username; 24 | protected $_apiKey; 25 | 26 | protected $_requestBody; 27 | protected $_requestUrl; 28 | 29 | protected $_responseBody; 30 | protected $_responseInfo; 31 | 32 | const SMS_URL = 'https://api.africastalking.com/version1/messaging'; 33 | const VOICE_URL = 'https://voice.africastalking.com'; 34 | const USER_DATA_URL = 'https://api.africastalking.com/version1/user'; 35 | const SUBSCRIPTION_URL = 'https://api.africastalking.com/version1/subscription'; 36 | const AIRTIME_URL = 'https://api.africastalking.com/version1/airtime'; 37 | 38 | 39 | //Turn this on if you run into problems. It will print the raw HTTP response from our server 40 | const Debug = false; 41 | 42 | const HTTP_CODE_OK = 200; 43 | const HTTP_CODE_CREATED = 201; 44 | 45 | public function __construct() 46 | { 47 | $this->_username = \Config::get('AfricasTalkingGateway.username'); 48 | $this->_apiKey = \Config::get('AfricasTalkingGateway.api_key'); 49 | 50 | $this->_requestBody = null; 51 | $this->_requestUrl = null; 52 | 53 | $this->_responseBody = null; 54 | $this->_responseInfo = null; 55 | } 56 | 57 | 58 | //Messaging methods 59 | public function sendMessage($to_, $message_, $from_ = null, $bulkSMSMode_ = 1, Array $options_ = array()) 60 | { 61 | if ( strlen($to_) == 0 || strlen($message_) == 0 ) { 62 | throw new AfricasTalkingGatewayException('Please supply both to and message parameters'); 63 | } 64 | 65 | $params = array( 66 | 'username' => $this->_username, 67 | 'to' => $to_, 68 | 'message' => $message_, 69 | ); 70 | 71 | if ( $from_ !== null ) { 72 | $params['from'] = $from_; 73 | $params['bulkSMSMode'] = $bulkSMSMode_; 74 | } 75 | 76 | //This contains a list of parameters that can be passed in $options_ parameter 77 | if ( count($options_) > 0 ) { 78 | $allowedKeys = array ( 79 | 'enqueue', 80 | 'keyword', 81 | 'linkId', 82 | 'retryDurationInHours' 83 | ); 84 | 85 | //Check whether data has been passed in options_ parameter 86 | foreach ( $options_ as $key => $value ) { 87 | if ( in_array($key, $allowedKeys) && strlen($value) > 0 ) { 88 | $params[$key] = $value; 89 | } else { 90 | throw new AfricasTalkingGatewayException("Invalid key in options array: [$key]"); 91 | } 92 | } 93 | } 94 | 95 | $this->_requestUrl = self::SMS_URL; 96 | $this->_requestBody = http_build_query($params, '', '&'); 97 | 98 | $this->executePOST(); 99 | 100 | if ( $this->_responseInfo['http_code'] == self::HTTP_CODE_CREATED ) { 101 | $responseObject = json_decode($this->_responseBody); 102 | return $responseObject->SMSMessageData->Recipients; 103 | } 104 | 105 | throw new AfricasTalkingGatewayException($this->_responseBody); 106 | } 107 | 108 | 109 | public function fetchMessages($lastReceivedId_) 110 | { 111 | $username = $this->_username; 112 | $this->_requestUrl = self::SMS_URL.'?username='.$username.'&lastReceivedId='. intval($lastReceivedId_); 113 | 114 | $this->executeGet(); 115 | 116 | if ( $this->_responseInfo['http_code'] == self::HTTP_CODE_OK ) { 117 | $responseObject = json_decode($this->_responseBody); 118 | return $responseObject->SMSMessageData->Messages; 119 | } 120 | 121 | throw new AfricasTalkingGatewayException($this->_responseBody); 122 | } 123 | 124 | 125 | //Subscription methods 126 | public function createSubscription($phoneNumber_, $shortCode_, $keyword_) 127 | { 128 | 129 | if ( strlen($phoneNumber_) == 0 || strlen($shortCode_) == 0 || strlen($keyword_) == 0 ) { 130 | throw new AfricasTalkingGatewayException('Please supply phoneNumber, shortCode and keyword'); 131 | } 132 | 133 | $params = array( 134 | 'username' => $this->_username, 135 | 'phoneNumber' => $phoneNumber_, 136 | 'shortCode' => $shortCode_, 137 | 'keyword' => $keyword_ 138 | ); 139 | 140 | $this->_requestUrl = self::SUBSCRIPTION_URL."/create"; 141 | $this->_requestBody = http_build_query($params, '', '&'); 142 | 143 | $this->executePOST(); 144 | 145 | if ( $this->_responseInfo['http_code'] != self::HTTP_CODE_CREATED ) 146 | throw new AfricasTalkingGatewayException($this->_responseBody); 147 | 148 | return json_decode($this->_responseBody); 149 | } 150 | 151 | public function deleteSubscription($phoneNumber_, $shortCode_, $keyword_) 152 | { 153 | if ( strlen($phoneNumber_) == 0 || strlen($shortCode_) == 0 || strlen($keyword_) == 0 ) { 154 | throw new AfricasTalkingGatewayException('Please supply phoneNumber, shortCode and keyword'); 155 | } 156 | 157 | $params = array( 158 | 'username' => $this->_username, 159 | 'phoneNumber' => $phoneNumber_, 160 | 'shortCode' => $shortCode_, 161 | 'keyword' => $keyword_ 162 | ); 163 | 164 | $this->_requestUrl = self::SUBSCRIPTION_URL."/delete"; 165 | $this->_requestBody = http_build_query($params, '', '&'); 166 | 167 | $this->executePOST(); 168 | 169 | if ( $this->_responseInfo['http_code'] != self::HTTP_CODE_CREATED ) 170 | throw new AfricasTalkingGatewayException($this->_responseBody); 171 | 172 | return json_decode($this->_responseBody); 173 | 174 | } 175 | 176 | public function fetchPremiumSubscriptions($shortCode_, $keyword_, $lastReceivedId_ = 0) 177 | { 178 | $username = $this->_username; 179 | $this->_requestUrl = self::SUBSCRIPTION_URL.'?username='.$username.'&shortCode='.$shortCode_; 180 | $this->_requestUrl .= '&keyword='.$keyword_.'&lastReceivedId='.intval($lastReceivedId_); 181 | 182 | $this->executeGet(); 183 | 184 | if ( $this->_responseInfo['http_code'] == self::HTTP_CODE_OK ) { 185 | $responseObject = json_decode($this->_responseBody); 186 | return $responseObject->responses; 187 | } 188 | 189 | throw new AfricasTalkingGatewayException($this->_responseBody); 190 | } 191 | 192 | 193 | //Call methods 194 | public function call($from_, $to_) 195 | { 196 | if ( strlen($from_) == 0 || strlen($to_) == 0 ) { 197 | throw new AfricasTalkingGatewayException('Please supply both from and to parameters'); 198 | } 199 | 200 | $params = array( 201 | 'username' => $this->_username, 202 | 'from' => $from_, 203 | 'to' => $to_ 204 | ); 205 | 206 | $this->_requestUrl = self::VOICE_URL . "/call"; 207 | $this->_requestBody = http_build_query($params, '', '&'); 208 | 209 | $this->executePOST(); 210 | 211 | if(($responseObject = json_decode($this->_responseBody)) !== null) { 212 | if(strtoupper(trim($responseObject->errorMessage)) == "NONE") { 213 | return $responseObject->entries; 214 | } 215 | throw new AfricasTalkingGatewayException($responseObject->errorMessage); 216 | } 217 | else 218 | throw new AfricasTalkingGatewayException($this->_responseBody); 219 | } 220 | 221 | public function getNumQueuedCalls($phoneNumber_, $queueName = null) 222 | { 223 | $this->_requestUrl = self::VOICE_URL . "/queueStatus"; 224 | $params = array( 225 | "username" => $this->_username, 226 | "phoneNumbers" => $phoneNumber_ 227 | ); 228 | if($queueName !== null) 229 | $params['queueName'] = $queueName; 230 | $this->_requestBody = http_build_query($params, '', '&'); 231 | $this->executePOST(); 232 | 233 | if(($responseObject = json_decode($this->_responseBody)) !== null) { 234 | if(strtoupper(trim($responseObject->errorMessage)) == "NONE") 235 | return $responseObject->entries; 236 | throw new AfricasTalkingGatewayException($responseObject->ErrorMessage); 237 | } 238 | 239 | throw new AfricasTalkingGatewayException($this->_responseBody); 240 | } 241 | 242 | 243 | public function uploadMediaFile($url_) 244 | { 245 | $params = array( 246 | "username" => $this->_username, 247 | "url" => $url_ 248 | ); 249 | 250 | $this->_requestBody = http_build_query($params, '', '&'); 251 | $this->_requestUrl = self::VOICE_URL . "/mediaUpload"; 252 | 253 | $this->executePOST(); 254 | 255 | if(($responseObject = json_decode($this->_responseBody)) !== null) { 256 | if(strtoupper(trim($responseObject->errorMessage)) != "NONE") 257 | throw new AfricasTalkingGatewayException($responseObject->errorMessage); 258 | } 259 | else 260 | throw new AfricasTalkingGatewayException($this->_responseBody); 261 | } 262 | 263 | 264 | //Airtime method 265 | public function sendAirtime($recipients) 266 | { 267 | $params = array( 268 | "username" => $this->_username, 269 | "recipients" => $recipients 270 | ); 271 | $this->_requestUrl = self::AIRTIME_URL . "/send"; 272 | $this->_requestBody = http_build_query($params, '', '&'); 273 | 274 | $this->executePOST(); 275 | 276 | if($this->_responseInfo['http_code'] == self::HTTP_CODE_CREATED) { 277 | $responseObject = json_decode($this->_responseBody); 278 | if(count($responseObject->responses) > 0) 279 | return $responseObject->responses; 280 | 281 | throw new AfricasTalkingGatewayException($responseObject->errorMessage); 282 | } 283 | 284 | throw new AfricasTalkingGatewayException($this->_responseBody); 285 | } 286 | 287 | //User info method 288 | public function getUserData() 289 | { 290 | $username = $this->_username; 291 | $this->_requestUrl = self::USER_DATA_URL.'?username='.$username; 292 | $this->executeGet(); 293 | 294 | if ( $this->_responseInfo['http_code'] == self::HTTP_CODE_OK ) { 295 | $responseObject = json_decode($this->_responseBody); 296 | return $responseObject->UserData; 297 | } 298 | 299 | throw new AfricasTalkingGatewayException($this->_responseBody); 300 | } 301 | 302 | private function executeGet () 303 | { 304 | $ch = curl_init(); 305 | $this->doExecute($ch); 306 | } 307 | 308 | private function executePost () 309 | { 310 | $ch = curl_init(); 311 | curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_requestBody); 312 | curl_setopt($ch, CURLOPT_POST, 1); 313 | $this->doExecute($ch); 314 | } 315 | 316 | private function doExecute (&$curlHandle_) 317 | { 318 | try { 319 | 320 | $this->setCurlOpts($curlHandle_); 321 | $responseBody = curl_exec($curlHandle_); 322 | 323 | if ( self::Debug ) { 324 | echo "Full response: ". print_r($responseBody, true)."\n"; 325 | } 326 | 327 | $this->_responseInfo = curl_getinfo($curlHandle_); 328 | 329 | $this->_responseBody = $responseBody; 330 | curl_close($curlHandle_); 331 | } 332 | 333 | catch(Exeption $e) { 334 | curl_close($curlHandle_); 335 | throw $e; 336 | } 337 | } 338 | 339 | private function setCurlOpts (&$curlHandle_) 340 | { 341 | curl_setopt($curlHandle_, CURLOPT_TIMEOUT, 60); 342 | curl_setopt($curlHandle_, CURLOPT_SSL_VERIFYPEER, FALSE); 343 | curl_setopt($curlHandle_, CURLOPT_URL, $this->_requestUrl); 344 | curl_setopt($curlHandle_, CURLOPT_RETURNTRANSFER, true); 345 | curl_setopt($curlHandle_, CURLOPT_HTTPHEADER, array ('Accept: application/json', 346 | 'apikey: ' . $this->_apiKey)); 347 | } 348 | } 349 | -------------------------------------------------------------------------------- /src/AfricasTalkingLaravel5Facade.php: -------------------------------------------------------------------------------- 1 | publishes([ 16 | __DIR__.'/config/config.php' => config_path('AfricasTalkingGateway.php'), 17 | ]); 18 | 19 | // use the vendor configuration file as fallback 20 | $this->mergeConfigFrom( 21 | __DIR__.'/config/config.php', 'AfricasTalkingGateway' 22 | ); 23 | } 24 | 25 | public function register() 26 | { 27 | $this->registerAfricasTalkingGateway(); 28 | 29 | // use this if your package has a config file 30 | config([ 31 | 'config/AfricasTalkingGateway.php', 32 | ]); 33 | } 34 | private function registerAfricasTalkingGateway() 35 | { 36 | $this->app->bind('AfricasTalkingGateway',function($app){ 37 | return new AfricasTalkingGateway($app); 38 | }); 39 | } 40 | } -------------------------------------------------------------------------------- /src/Http/routes.php: -------------------------------------------------------------------------------- 1 | 'Your Username here', 4 | 'api_key' => 'Your API key here', 5 | ]; 6 | 7 | --------------------------------------------------------------------------------