Skip to content

Instantly share code, notes, and snippets.

@dice
Created August 20, 2012 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dice/3401559 to your computer and use it in GitHub Desktop.
Save dice/3401559 to your computer and use it in GitHub Desktop.
PHP code snippet for FullCourt SMS Authentication Sample Code
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