Freeside:1.9:Documentation:Developer/FS/SelfService/php/php examples

From Freeside
< Freeside:1.9:Documentation:Developer‎ | FS‎ | SelfService
Revision as of 18:27, 6 April 2010 by Huntsberg (talk | contribs) (New page: <pre> <? require('freeside.class.php'); $freeside = new FreesideSelfService(); $domain = 'example.com'; $response = $freeside->login( array( 'username' => strtolower($_POST['username...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
<?

require('freeside.class.php');
$freeside = new FreesideSelfService();

$domain = 'example.com';

$response = $freeside->login( array( 
  'username' => strtolower($_POST['username']),
  'domain'   => $domain,
  'password' => strtolower($_POST['password']),
) );

error_log("[login] received response from freeside: $response");
$error = $response['error'];

if ( ! $error ) {

    // sucessful login

    $session_id = $response['session_id'];

    error_log("[login] logged into freeside with session_id=$session_id");

    // store session id in your session store, to be used for other calls

} else {

    // unsucessful login

    error_log("[login] error logging into freeside: $error");

    // display error message to user

}

?>