function retrieve_contacts($import_id, $timeout) { $contacts_result = CSImport::get_contacts($import_id); $contacts = $contacts_result['contacts']; $contacts_owner = $contacts_result['contacts_owner']; if (!is_null($contacts_owner)) { echo "<p><strong>Contacts Owner</strong>:"; echo $contacts_owner->name(); echo "<" . $contacts_owner->email() . ">"; echo "</p>"; } if (!is_null($contacts)) { echo "<pre>"; print_r($contacts); echo "</pre>"; ?> <script type="text/javascript"> popup = window.open('', '_popupWindow'); if (undefined != popup) { popup.close(); } </script> <?php } }
function retrieve_events($import_id, $timeout) { $continue = false; $reload = true; $events = CSImport::get_events($import_id); foreach ($events as $event) { // look for an error event... if ($event['status'] == 'ERROR') { $reload = false; echo $event['description']; } // look for the COMPLETED/COMPLETE event... this indicates the import is completely done if ($event['event_type'] == "COMPLETE" && $event['status'] == "COMPLETED" && $event['value'] == 0) { $continue = true; $reload = false; } } if (!is_null($events)) { echo "<pre>"; print_r($events); echo "</pre>"; } if ($reload) { ?> <script type="text/javascript"> // only execute the timeout if the popup is still open, if the user canceled by closing it, then we are done... // This could be cleaned up by using ajax, instead of an entire page refresh setTimeout("window.location = 'step_2_events.php?import_id=<?php echo $import_id; ?> '", <?php echo $timeout; ?> ); </script> <?php } else { if ($continue) { // redirect the page to the final step. ?> <script type="text/javascript"> window.location = 'step_3_contacts.php?import_id=<?php echo $import_id; ?> '; </script> <?php } } }
?> "/> <br /> FORM Body:<br /> <textarea rows="10" cols="40" name="body"><?php echo $_GET['body']; ?> </textarea> <br /> <input type="submit"/> </form> <hr/> <?php require_once 'csimport.php'; // print_r($_GET['url']); // print_r($_GET['body']); // echo CSImport::forward_auth($_GET, $_POST); if ($_GET['body']) { print "posting to url: {$_GET['url']} <br/>"; print_r(CSImport::post_url($_GET['url'], $_GET['body'])); } else { print "getting url: " + $_GET['url'] + "<br/>"; print_r(CSImport::get_url($_GET['url'])); } ?> <hr /> </body> </html>
<?php // CloudSponge.com PHP Library v0.9 Beta // http://www.cloudsponge.com // Copyright (c) 2010 Cloud Copy, Inc. // Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php // // Written by Graeme Rouse // graeme@cloudsponge.com require_once 'csimport.php'; $response = CSImport::forward_auth($_GET, $_POST); if (isset($response['redirect'])) { // This is our successful case // calling header(..) only works if no body // content has been sent yet. If you are integrating this // page in a web application framework, // you may need to redirect differently. // E.g. With Kohana: // url::redirect($response['redirect']); header($response['redirect']); } else { // We shouldn't get here echo $response['body']; } // calling exit here to ensure that the response is sent, event if there is no body content. // Thanks to Chris McKeever of GiveForward.com for discovering this issue when integrating with Kohana. exit;
static function get_url($url) { return CSImport::url_request($url); }
</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..."; } }