Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Karol Janyst  >  Contacts importer  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example file
Class: Contacts importer
Import contacts from Web mail accounts
Author: By
Last change: Comments correct
Date: 2009-06-08 12:20
Size: 1,911 bytes
 

Contents

Class file image Download
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <meta http-equiv="pragma" content="no-cache"/>
</head>
<body>
<?php
  
// include class file
  
require_once('contacts_importer.class.php');
  
  
// creating new Contacts Importer object
  
$import = new ContactsImporter;

  
// set temp directory (necessary for storage Windows Live config)
  
$import->TempDir '/tmp/';
  
  
// set URL to which script will return after authorization (GMail and Windows Live)
  
$import->returnURL 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];

  
// Windows Live requires policy file, it could be anything
  
$import->WLLPolicy 'http://'.$_SERVER['SERVER_NAME'].'policy.php';
  
// set API key for created application on Windows Live
  
$import->WLLAPIid '<insert your API key here>';
  
// set your secret phrase for Windows Live application
  
$import->WLLSecret '<insert your secret phrase here>';

  
// set API key for Yahoo application
  
$import->YahooAPIid '<insert your API key here>';
  
// set secret phrase for Yahoo application
  
$import->YahooSecret '<insert your secret phrase here>';
  
  
//prints out authorization links for all 3 services
  
echo '<a href="'.$import->getGMailLink().'">GMail</a>';
  echo 
'<a href="'.$import->getWLLLink().'">Hotmail</a>';
  echo 
'<a href="'.$import->getYahooLink().'">Yahoo</a>';

  
// fetches contacts from authorized mail service
  
$contacts $import->getContacts();

  
// prints out all fetched contacts
  // data structure is:
  // $contact->name - for name of the contact
  // $contact->email - for email address
  
if (!empty($contacts)) {
      echo 
'<pre>';
    
print_r($contacts);
    echo 
'</pre>';
  }
?>
</body>
</html>