-
Notifications
You must be signed in to change notification settings - Fork 6
/
popup.php
45 lines (43 loc) · 1.43 KB
/
popup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<html>
<head>
<title>Import Contacts - Popup</title>
</head>
<body>
<?php
require_once 'csimport.php';
if (array_key_exists('service', $_GET)) {
// Step 1
$username = NULL;
$password = NULL;
if (array_key_exists('username', $_GET))
$username = $_GET['username'];
if (array_key_exists('password', $_GET))
$password = $_GET['password'];
// Call to the CloudSponge.com for the import_id and redirect url (if applicable)
$output = CSImport::begin_import($_GET['service'], $username, $password, NULL, NULL, array('include' => "name,email,mailing_address"));
if (isset($output['import_id']))
{
$import_id = $output['import_id'];
if (!is_null($output['consent_url'])) {
$url = $output['consent_url'];
// header("Location: $url"); // not here since we need to redirec the opener window...
} else if (!is_null($output['applet_tag'])) {
// TODO: add description here of what to do next...
echo $output['applet_tag'];
}
} else {
echo "trouble...";
}
}
?>
<p>Contacts are being imported. Please do not close this popup window. </p>
<script type="text/javascript">
// redirect the opener to start fetching events and updating with the current progress
window.opener.location = 'step_2_events.php?import_id=<?php echo $import_id; ?>';
<?php if (isset($url)) { ?>
// redirect the popup to the appropriate url
this.location = '<?php echo $url; ?>';
<?php } ?>
</script>
</body>
</html>