Skip to content

Msn contact grabber

World Wide Web Server edited this page Jul 4, 2012 · 6 revisions

Hi all,

After several attempts I managed to integrate a library for CodeIgniter extract hotmail contacts and so a user can send invitations for example, just how does facebook, hi5 .. etc.

These libraries are made on the basis phpListgrab and MSNPauth the Daniel Winter.

In this moment, i use two libraries.. but later y make only one whit other sources.

You can use this library.. sending the email and password beetwen ajax and return a message for the result the process.

so.. go it!!

Controller

[code] function import_msn() {
$this->load->model('modemsn','import_msg'); if($this->import_msg->grabber_msn()){ echo $this->set_msg('ok!!!'); }else{ echo $this->set_msg('failed'); } } [/code]

Now, supose what you send in the form the parameters the account e-mail and password.. i load the model.. in the model have the code for conect to msn and extract the contacts.

Model

[code] . . . . function grabber_msn() {

$params = array('user' => $this->input->post('user'), 'password' => $this->input->post('password'));

$this->load->library('phpListgrab', $params);

$ret = $this->phplistgrab->grab();

if (!$ret)
{
    switch ($this->phplistgrab->result)
    {
        case ERR_AUTHENTICATION_FAILED:
            echo '<p>Authentication failed.</p>';
            break;

        case ERR_SERVER_UNAVAILABLE:
            echo '<p>Failed to connect to server.</p>';
            break;
    }

}

foreach ($this->phplistgrab->lists[LIST_FORWARD] as $contact)
{
    $ndatos = array (
    'id_usuario' => $this->session->userdata('id'),
    'friend' => $contact['passport']);

     $this->db->insert('import_contacts',$ndatos);
}


}

[/code]

Explanation So.. in the model i make a array for send the data account the user.. this array send whit parameter to the library whe its load.

later, call the function grab and storage the result in $ret for check if connect or not to the service.

and in the last part.. call the function "lists" for retrive the contact information, in this case.. i read the data and storage inmediatly in the database, using whit id_usuario, the id th user what give the friends.

In the zip file, you hace two files.

phplistgrabber = class msnpauth = class

Put this class in your folder libraries and enjoy!

File:phplistgrabber.zip

http://codeigniter.com/wiki/24c7097bb6fb6a2799edcd97aefa972f/

Clone this wiki locally