Created
May 7, 2018 13:30
-
-
Save tjlytle/0e2699867d662b46d49b3351b37ce3f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once __DIR__ . '/vendor/autoload.php'; | |
$client = new \Nexmo\Client(new \Nexmo\Client\Credentials\Basic(NEXMO_KEY, NEXMO_SECRET)); | |
try { | |
$inbound = \Nexmo\Message\InboundMessage::createFromGlobals(); | |
} catch (Exception $e) { | |
error_log('could not parse inbound message'); | |
} | |
// here's where you need to do something to store the inbound phone number | |
error_log('got message from: ' . $inbound->getFrom()); | |
if ('yes' === strtolower(substr($inbound->getBody(), 0, 3))) { | |
$reply = $inbound->createReply("Here's a link: http://example.com"); | |
} | |
// perhaps other keywords | |
if (!isset($reply)) { | |
return; | |
} | |
try { | |
$client->message()->send($reply); | |
} catch (Exception $e) { | |
error_log('could not send reply: ' . $e->getMessage()); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment