<?php

/*
	This is a simple example script that shows how easy is to integrate your application within draugiem.lv.
	Feel free to use it in your own projects.
*/
include 'DraugiemApi.php';
$app_key = 'd6949661ccde33a65d98653043bc3119';
//Application API key of your app goes here
$app_id = 999;
//Application ID of your app goes here
$draugiem = new DraugiemApi($app_id, $app_key);
//Create Passport object
session_start();
//Start PHP session
$draugiem->cookieFix();
//Iframe cookie workaround for IE and Safari
$session = $draugiem->getSession();
//Authenticate user
if ($session) {
    //Authentication successful
    $user = $draugiem->getUserData();
    //Get user info
    ?>
<html>
	<head>
		<title>Draugiem API test</title>
<?php 
    echo $draugiem->getJavascript('body', 'http://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER['PHP_SELF']) . '/callback.html');
    //Set up JS API + iframe Resize
    ?>
Example #2
0
	This is a simple example script that shows how easy is to integrate your page with Draugiem.lv Passport.
	Feel free to use it in your own projects.
*/
$app_key = 'd6949661ccde33a65d98653043bc3119';
//Application API key of your app goes here
$app_id = 999;
//Application ID of your app goes here
session_start();
//Start PHP session
if (isset($_GET['logout'])) {
    //Logout
    session_destroy();
    header('Location: ?');
}
include 'DraugiemApi.php';
$draugiem = new DraugiemApi($app_id, $app_key);
//Create Draugiem.lv API object
$session = $draugiem->getSession();
//Try to authenticate user
if ($session && !empty($_GET['dr_auth_code'])) {
    //New session, check if we are not redirected from popup
    if (!empty($_GET['dr_popup'])) {
        //Redirected from popup, refresh parent window and close the popup with Javascript
        ?>
		<script type="text/javascript">
		window.opener.location.reload();
		window.opener.focus();
		if(window.opener!=window){
			window.close();
		}
		</script>