Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'vendor/autoload.php';
- use AfricasTalking\SDK\AfricasTalking;
- $username = "sandbox";
- $apiKey = "6e415c0bd1b320e053ab8d9131118185dd16d6d397438dc6ad0d859f6ab084ac";
- $AT = new AfricasTalking($username, $apiKey);
- $message = "VR-12345";
- // Router
- $router = new AltoRouter();
- $router->map( 'GET', '/', function() {
- require __DIR__ . '/views/login.php';
- });
- $router->map( 'GET|POST', '/login/[*:password]', function ($password) {
- if($_GET["username"] == "user1" && $password =="pass1"){
- global $AT;
- $sms = $AT->sms();
- $response = $sms->send(array(
- "to" => "+254705336634",
- "message" => "VR-12345"
- ));
- header("Content-Type: application/json; charset=UTF-8");
- echo json_encode($response);
- }
- else{
- echo json_encode($response);
- }
- });
- $router->map( 'GET|POST', '/verify/[*:verify]', function ($verify) {
- if($verify == $message){
- echo json_encode($response);
- // require __DIR__ . '/views/verify.php';
- }
- });
- $match = $router->match();
- if( $match && is_callable( $match['target'] ) ) {
- call_user_func_array( $match['target'], $match['params'] );
- } else {
- header( $_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found');
- }
Add Comment
Please, Sign In to add comment