SAPO Mail WebServices
Upcoming SlideShare
Loading in...5
×
 

SAPO Mail WebServices

on

  • 22,540 views

SAPO Mail, API de acesso ao Webmail

SAPO Mail, API de acesso ao Webmail

Statistics

Views

Total Views
22,540
Views on SlideShare
21,940
Embed Views
600

Actions

Likes
1
Downloads
81
Comments
0

7 Embeds 600

http://mail.blogs.sapo.pt 517
http://intra.codebits.sapo.pt 56
http://www.slideshare.net 22
http://blogs.sapo.pt 2
http://www.netvibes.com 1
http://aulavirtual.ingenieriausp.com 1
http://localhost 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

SAPO Mail WebServices SAPO Mail WebServices Presentation Transcript

  • SAPO Mail - Webservices 14 de Novembro 2007 •Nuno Loureiro <nuno@co.sapo.pt> •Carlos Pires <acmpires@co.sapo.pt> •André Luís <aluis@co.sapo.pt>
  • SAPO Mail - Webservices Arquitectura Aspectos Gerais Credenciais Mail Contactos Exemplos Práticos
  • Arquitectura do Webmail
  • SAPO Mail - Webservices Arquitectura Aspectos Gerais Credenciais Mail Contactos Exemplos Práticos
  • Mail Webservices - Aspectos Gerais Operações disponíveis: Mail: GetStatus; GetLastMails; GetMailbox; Contactos: ListAllContacts; GetContact; AddContact; DeleteContact; SearchContacts; SetContact.
  • Mail Webservices - Aspectos Gerais End-Point: http://services.sapo.pt/Mail WSDL: http://services.sapo.pt/Metadata/Contract/Mail Namespace: http://services.sapo.pt/definitions Exemplo Prático: http://services.mail.sapo.pt/codebits Operator (Firefox): http://addons.mozilla.org/en-US/firefox/addon/4106 User-script para Operator (Firefox): http://services.mail.sapo.pt/operator/js/sapomail.js
  • SAPO Mail - Webservices Arquitectura Aspectos Gerais Credenciais Mail Contactos Exemplos Práticos
  • Mail Webservices - Credenciais - Objecto ESBCredentials 1 ESBCredentials • ESBUsername • ESBPassword Usado para a autenticação nos webservices do mail; Todas as operações dos webservices do mail requerem a definição de um SOAP Header com as credenciais do utilizador. class ESBCredentials { public $ESBUsername; //string public $ESBPassword; //string }
  • SAPO Mail - Webservices Arquitectura Aspectos Gerais Credenciais Mail Contactos Exemplos Práticos
  • Mail Webservices - Mail - Objectos 1 Mailbox • Status • ArrayOfLastMail ArrayOfLastMail • PageInfo • LastMail Status PageInfo LastMail • Total • PageNumber • MessageId • Recent • Unseen • RecordsCount • FromName • Answered • Recent • MaxRecords • FromEMail • Deleted • Subject • Flagged • Date • Size (in bytes) • Seen
  • Mail Webservices - Mail - Operações (1) GetStatus GetStatus class Status { public $Total; //int public $Unseen; //int public $Recent; //int }
  • Mail Webservices - Mail - Operações (2) GetLastMails GetLastMails • page (1 by default) • limit (10 by default, max 50)  Headers das mensagens pedidas;  Ordenação: ARRIVAL DATE DESC class ArrayOfLastMail { public $PageInfo; public $LastMail = array(); class LastMail { } public $MessageId; //int (imap uid) public $FromName; //string public $FromEMail; //string public $Subject; //string public $Date; //string class PageInfo { public $Seen; //boolean public $PageNumber; //int public $Recent; //boolean public $RecordsCount; //int public $Answered; //boolean public $MaxRecords; //int public $Deleted; //boolean } public $Flagged; //booelan public $Size; //int (in bytes) }
  • Mail Webservices - Mail - Operações (3) GetMailbox GetMailbox • page (1 by default) • limit (10 by default, max 50) class Mailbox { public $Status; public $ArrayOfLastMail; class ArrayOfLastMail { } public $PageInfo; //PageInfo public $LastMail = array(); //LastMail } class Status { public $Total; //int  Headers das mensagens pedidas; public $Unseen; //int public $Recent; //int  Ordenação: ARRIVAL DATE DESC }
  • Mail Webservices - Mail
  • SAPO Mail - Webservices Arquitectura Aspectos Gerais Credenciais Mail Contactos Exemplos Práticos
  • Mail Webservices - Contactos - Objectos 1 ArrayOfContact • ContactInfo • Contact ContactInfo Contact • ContactId • CellPhone • RecordsCount • Name • Fax • SearchExpression (opcional) • Alias • Title • Email • Company • HomeAddress • Notes • WorkAddress • PGPPublicKey • HomePhone • SMimePublicKey • WorkPhone • FreeBusyURL
  • Mail Webservices - Contactos - Operações (1) ListAllContacts ListAllContacts class Contact { public $ContactId; //string public $Name; //string class ArrayOfContact { public $Alias; //string public $ContactInfo; public $Email; //string public $Contact = array(); public $HomeAddress; //string } public $WorkAddress; //string public $HomePhone; //string public $WorkPhone; //string public $CellPhone; //string public $Fax; //string public $Title; //string class ContactInfo { public $Company; //string public $RecordsCount; //int public $Notes; //string public $SearchExpression; //string public $PGPPublicKey; //string } public $SMimePublicKey; //string public $FreeBusyURL; //string }
  • Mail Webservices - Contactos - Operações (2) GetContact GetContact • ContactID (string) class Contact { public $ContactId; //string public $Name; //string public $Alias; //string public $Email; //string public $HomeAddress; //string public $WorkAddress; //string public $HomePhone; //string public $WorkPhone; //string public $CellPhone; //string public $Fax; //string public $Title; //string public $Company; //string public $Notes; //string public $PGPPublicKey; //string public $SMimePublicKey; //string public $FreeBusyURL; //string }
  • Mail Webservices - Contactos - Operações (3) AddContact AddContact • Contact (object)  Campo gerado pelo webservice:  ContactId;  Obrigatório:  Name. 057259c0271b5cf71bb8e9be7ace49e2 ContactId (hash md5)
  • Mail Webservices - Contactos - Operações (4) SetContact SetContact • ContactID (string) • Contact (object)  Campo ignorado pelo webservice:  ContactId; true false Sucesso Erro
  • Mail Webservices - Contactos - Operações (5) SearchContact SearchContact • SearchExpression (string != ‘’)  Nome  E-mail class Contact { class ArrayOfContact { public $ContactId; //string public $ContactInfo; public $Name; //string public $Contact = array(); public $Alias; //string } public $Email; //string public $HomeAddress; //string public $WorkAddress; //string public $HomePhone; //string public $WorkPhone; //string public $CellPhone; //string class ContactInfo { public $Fax; //string public $RecordsCount; //int public $Title; //string public $SearchExpression; //string public $Company; //string } public $Notes; //string public $PGPPublicKey; //string public $SMimePublicKey; //string public $FreeBusyURL; //string }
  • Mail Webservices - Contactos - Operações (6) DeleteContact DeleteContact • ContactID (string) true false Sucesso Erro
  • Mail Webservices - Contactos
  • Mail Webservices - Contactos
  • SAPO Mail - Webservices Arquitectura Aspectos Gerais Credenciais Mail Contactos Exemplos Práticos
  • Mail Webservices - Exemplos Práticos - SOAP Request <?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?> <SOAP-ENV:Envelope xmlns:SOAP-ENV=quot;http://schemas.xmlsoap.org/soap/envelope/quot; xmlns:ns1=quot;http://services.sapo.pt/definitionsquot;> <SOAP-ENV:Header> <ns1:ESBCredentials> <ns1:ESBUsername>someuser@sapo.pt</ns1:ESBUsername> <ns1:ESBPassword>somepass</ns1:ESBPassword> </ns1:ESBCredentials> </SOAP-ENV:Header> <SOAP-ENV:Body> <ns1:GetMailbox> <ns1:page>1</ns1:page> <ns1:limit>10</ns1:limit> </ns1:GetMailbox> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
  • Mail Webservices - Exemplos Práticos - SOAP Request <?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?> <SOAP-ENV:Envelope xmlns:SOAP-ENV=quot;http://schemas.xmlsoap.org/soap/envelope/quot; xmlns:ns1=quot;http://services.sapo.pt/definitionsquot;> <SOAP-ENV:Header> <ns1:ESBCredentials> <ns1:ESBUsername>someuser@sapo.pt</ns1:ESBUsername> <ns1:ESBPassword>somepass</ns1:ESBPassword> </ns1:ESBCredentials> </SOAP-ENV:Header> <SOAP-ENV:Body> <ns1:ListAllContacts/> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
  • Mail Webservices - Exemplos Práticos - PHP5 Client Example <?php require_once dirname(__FILE__) . '/Mail_client_conf.php'; // Config require_once dirname(__FILE__) . '/Mail_types.php'; // Class types $user = 'someuser@sapo.pt'; $pass = 'somepass'; $ESBC = new ESBCredentials_t(); $ESBC->ESBUsername = $user; $ESBC->ESBPassword = $pass; $GetMailbox = new GetMailbox_t(); $GetMailbox->page = 1; $GetMailbox->limit = 10; $paramMailbox = (isset($GetMailbox)) ? array('parameters' => $GetMailbox) : array(); // [ ---> Continua ]
  • Mail Webservices - Exemplos Práticos - PHP5 Client Example (2) $client = new SoapClient( /* This should be local, avoid one network call */ 'http://services.sapo.pt/Metadata/Contract/Mail', array('location' => quot;http://services.sapo.pt/Mailquot;, 'classmap' => $classmap) ); $header = new SoapHeader('http://services.sapo.pt/definitions', 'ESBCredentials', $ESBC); try { $response = $client->__soapCall('GetMailbox', $paramMailbox, null, $header); /* Your Code Here */ } catch (SoapFault $e) { $text = (!$e->getMessage()) ? $e->faultstring : $e->getMessage(); echo quot;SOAP FAULT: $textnquot;; } ?>
  • Mail Webservices - Exemplos Práticos - PHP CodeGenerator <?php require_once dirname(__FILE__) . '/Mail_client_conf.php'; require_once dirname(__FILE__) . '/Mail_client.php'; $client = new Mail_client($conf); $client->makeHeader('someuser@sapo.pt', 'somepass'); /* GetMailbox(page, limit) */ $response = $client->GetMailbox(1, 10); /* ListAllContacts */ //$response = $client->ListAllContacts(); /* AddContact(Contact) */ //$Contact = new Contact_t(); //$Contact->Name = 'somename'; // ... //$response = $client->AddContact($Contact); /* Your Code Here */ ?>
  • Mail Webservices - Exemplos Práticos - Em Acção (1) Agora é tempo de ver tudo isto em acção: Listagem de Mails e Contactos: Webservices: GetMailbox; ListAllContacts; Importação de contactos para o webmail: Webservices: AddContact; Ferramentas: Microformatos; Operator (extensão Firefox);
  • Mail Webservices - Exemplos Práticos - Em Acção (2) Screencasts de demos de utilização: ListAllContacts: http://services.mail.sapo.pt/codebits/swf/ListAllContacts.swf GetMailbox: http://services.mail.sapo.pt/codebits/swf/GetMailbox.swf Screencast de instalação e uso de um user-script para a extensão para Firefox Operator: Adicionar hCard de uma página ao webmail do SAPO: http://services.mail.sapo.pt/codebits/swf/Operator.swf
  • http://mail.blogs.sapo.pt/