Welcome Guest, Not a member yet? Register   Sign In
OpenInviter.com library wrapper
#8

[eluser]Twisted1919[/eluser]
Hi , this wrapper works with the following changes :

The inviter Class

Code:
<?php
/* [email protected] inviter.php Fri May 22 04:00:19 GMT 2009 */

class inviter
{
    var $ci;
    var $imported;
    
    public function __construct()
    {
        $this->ci=& get_instance();
    }

    public function grab_contacts($plugin,$username,$password)
    {
        require_once($this->ci->config->item('absolute_url').'OpenInviter/openinviter.php');
        
        $oi    = new OpenInviter();
        
        $oi->startPlugin($plugin);
        //First modification , added the if clause
        if($oi->login($username,$password))
        {
            $array        =     $oi->getMyContacts();
            
            if(is_array($array) && count($array)>=1)
            {
                $this->imported        =    $array;
                
                $this->_store_invited();
                
                return($this->imported);
            }else{
                return;
            }
        }
        else
        {
        return 'ERROR on login.';
        }
    }
    
    private function _store_invited()
    {
        foreach($this->imported as $mail=>$name)
        {
            //Second modification , commented out the user_id /

            $a    =    array(   /* 'user_id'        =>    ospc_user_id(),*/
                            'name'            =>    $name,
                            'email_address'    =>    $mail,
                            'status'        =>    0,
                            'time_imported'    =>    time()    );
                            
            $this->ci->db->insert('ospc_imported',$a);
            
            unset($a);
        }
    }
}
?>
Notice that i commented out the user_id key from $a array , just because it showed errors when was not commented .
Also i added an if clause for login , because previously , when the login failed there where some nasty errors but now, when login fails , it shows "ERROR on login." ans the script stops .

I tried as follows , in one of my controllers
Code:
function openinviter()
    {
    ini_set('display_errors',1);
    error_reporting(E_ALL);    
    $this->load->library('Inviter');    
    $plugin = 'yahoo';
    $username = $this->input->post('username');
    $password = $this->input->post('password');
    if(empty($username) || empty($password))
        {
        echo '<form action="" method="post">
        Username :<input type="text" name="username" />
        <br />
        Password:&lt;input type="text" name="password" /&gt;
        <br />
        &lt;input type="submit" name="submit" value="send"/&gt;
        &lt;/form&gt;';
        }
    else
        {
        $users = $this->inviter->grab_contacts($plugin,$username,$password)   ;
        echo '<pre>';
        print_r($users);
        echo '</pre>';
        }    
    }

And everything went ok ,it printed the array with the needed values .

Hope that helps someone Smile


Messages In This Thread
OpenInviter.com library wrapper - by El Forum - 05-22-2009, 03:25 PM
OpenInviter.com library wrapper - by El Forum - 05-22-2009, 03:37 PM
OpenInviter.com library wrapper - by El Forum - 05-22-2009, 03:40 PM
OpenInviter.com library wrapper - by El Forum - 06-24-2009, 05:33 AM
OpenInviter.com library wrapper - by El Forum - 07-03-2009, 06:34 AM
OpenInviter.com library wrapper - by El Forum - 07-06-2009, 12:32 AM
OpenInviter.com library wrapper - by El Forum - 07-10-2009, 01:44 PM
OpenInviter.com library wrapper - by El Forum - 07-13-2009, 02:25 PM
OpenInviter.com library wrapper - by El Forum - 07-28-2009, 05:32 AM
OpenInviter.com library wrapper - by El Forum - 07-30-2009, 12:26 AM
OpenInviter.com library wrapper - by El Forum - 07-30-2009, 11:33 PM
OpenInviter.com library wrapper - by El Forum - 08-26-2009, 07:05 PM
OpenInviter.com library wrapper - by El Forum - 11-25-2009, 03:13 AM
OpenInviter.com library wrapper - by El Forum - 01-07-2010, 03:54 PM
OpenInviter.com library wrapper - by El Forum - 02-13-2010, 02:21 PM
OpenInviter.com library wrapper - by El Forum - 05-08-2010, 05:36 AM
OpenInviter.com library wrapper - by El Forum - 06-22-2010, 08:54 AM
OpenInviter.com library wrapper - by El Forum - 07-09-2010, 12:58 AM
OpenInviter.com library wrapper - by El Forum - 09-22-2010, 08:08 AM
OpenInviter.com library wrapper - by El Forum - 10-03-2010, 04:10 AM
OpenInviter.com library wrapper - by El Forum - 03-11-2011, 05:04 AM
OpenInviter.com library wrapper - by El Forum - 03-12-2011, 06:11 AM
OpenInviter.com library wrapper - by El Forum - 03-14-2011, 05:52 AM
OpenInviter.com library wrapper - by El Forum - 05-15-2011, 08:21 PM
OpenInviter.com library wrapper - by El Forum - 06-13-2011, 07:08 PM
OpenInviter.com library wrapper - by El Forum - 07-10-2011, 02:57 AM
OpenInviter.com library wrapper - by El Forum - 07-10-2011, 02:58 AM
OpenInviter.com library wrapper - by El Forum - 02-07-2012, 08:37 AM
OpenInviter.com library wrapper - by El Forum - 08-31-2012, 06:05 PM



Theme © iAndrew 2016 - Forum software by © MyBB