Created
August 20, 2012 06:28
-
-
Save dice/3401559 to your computer and use it in GitHub Desktop.
PHP code snippet for FullCourt SMS Authentication Sample Code
This file contains 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
function user_generate_token($username, $phoneNum){ | |
global $accountsid, $authtoken, $fromNumber; | |
// Create a new password | |
$password = substr(md5(time().rand(0, 10^10)), 0, 5); | |
// Store the username and password. | |
$_SESSION['username'] = $username; | |
$_SESSION['password'] = $password; | |
/* Set our AccountSid and AuthToken */ | |
$accountsid= "FC20f8676ba75a63ba452784ca5858d217"; | |
$authtoken= "ocYw1LU8A9w64uztN5dKPzwrNH9ynmuXtx"; | |
$fromNumber="FullCourt"; | |
$client = new RestAPI($accountsid, $authtoken); | |
// Prepare the message with the password embedded | |
$content = "Your newly generated password is ".$password; | |
$params = array( | |
'To' => $phoneNum, | |
'From' => $fromNumber, | |
'Body' => $content | |
); | |
// Send the message via SMS or Voice | |
$item = $client->send_message($params); | |
$message = "A new password has been generated and sent to your phone number."; | |
return $message; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment