XMLRPC and Code Igniter to aMember

Discussion in 'Troubleshooting' started by aai2on, Jul 26, 2011.

  1. aai2on

    aai2on New Member

    Joined:
    Oct 16, 2008
    Messages:
    24
    Question.... xmlrpc query from Code Igniter to aMember to see if a users account exists.

    $this->load->library('xmlrpc');
    $this->xmlrpc->set_debug(TRUE) ;
    $this->xmlrpc->server('http://localhost/membership/xmlrpc/index.php', 80);
    $this->xmlrpc->timeout(60);
    $this->xmlrpc->method('check_uniq_login');

    $request = array(
    array(
    'login' => 'test',
    'pass' => sha1('password'),
    'email' => 'test@test.com',
    'check_type' => 2,
    ),'struct'
    );

    $this->xmlrpc->request($request);

    if ($this->xmlrpc->send_request()) {
    echo '<pre>';
    print_r($this->xmlrpc->display_response());
    echo '</pre>';
    }
    else {
    echo $this->xmlrpc->display_error();
    }

    I am getting: Did not receive a '200 OK' response from remote server. (HTTP/1.0 401 Unauthorized)

    Does this look right? I just want to get an initial query to work.
  2. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
  3. aai2on

    aai2on New Member

    Joined:
    Oct 16, 2008
    Messages:
    24
    Code Igniter xmlrpc

    I am trying to see if a users login exists. However, I get:


    Error #8003 - XML-RPC username is not entered
    Did not receive a '200 OK' response from remote server. (HTTP/1.0 401 Unauthorized)Array ( )

    Anyone have some insight into why this doesn't work. The test account exists under Configuration->Advanced->xmlrpc (enabled, etc)

    $this->load->library('xmlrpc');
    $this->xmlrpc->set_debug(TRUE) ;
    $this->xmlrpc->server('http://localhost/membership/xmlrpc/index.php', 80);
    $this->xmlrpc->timeout(60);
    $this->xmlrpc->method('check_login');

    $request = array(array('login' => 'test', 'pass' => sha1('test'),),'struct');
    $this->xmlrpc->request($request);

    if ($this->xmlrpc->send_request()) {
    echo '<pre>';
    print_r($this->xmlrpc->display_response());
    echo '</pre>';
    }
    else {
    echo $this->xmlrpc->display_error();
    }
  4. aai2on

    aai2on New Member

    Joined:
    Oct 16, 2008
    Messages:
    24
    After looking into the aMember code, it appears that

    $_SERVER['PHP_AUTH_USER']
    $_SERVER['PHP_AUTH_PW']

    are never set utilizing Code Igniter. At least from digging through the code.
  5. aai2on

    aai2on New Member

    Joined:
    Oct 16, 2008
    Messages:
    24
    Took a different approach:

    include_once(dirname(__FILE__) . '/amember/xmlrpc/ixr.inc.php');

    $client = new IXR_Client('http://localhost/amember/xmlrpc/index.php');
    $client->auth_login = 'test';
    $client->auth_pass = 'test';

    //get list of all products in aMember
    $client->query('get_products_list');
    $response = $client->getResponse();
    echo "

    ";
    print_r($response);

    This works for me with a few minor changes....
  6. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    These variables are set automatically.
    have a look:
    http://www.php.net/manual/en/features.http-auth.php

Share This Page