Retrieving Data

Discussion in 'Customization & add-ons' started by amadeus, Jun 14, 2009.

  1. amadeus

    amadeus Member

    Joined:
    Jan 16, 2009
    Messages:
    42
    I am doing some research here before purchasing -- so, I apologize if this is a stupid question.

    Basically, my software sends an http request to a PHP file that includes the users login, password, and subscription type. That PHP file would then query the amember system/database and find out the current status. Then, the PHP file would send back information based upon what it determined.

    Of course, I know how to do everything just getting information from the MySQL database directly. However, the 'data' field in the "members" table complicates things immensely.

    Anyway, can someone give a simple example of a complete .php script that would utilize the amember system and return the current subscription types and current status on those? The wiki gives snippets of how to get information once you're "logged in" ..but, not how one would log in with a standalone script.
  2. amadeus

    amadeus Member

    Joined:
    Jan 16, 2009
    Messages:
    42
    After looking over everything in the wiki, I think that really what I need is a way to retrieve $_SESSION['_amember_user'] and $_SESSION['_amember_product_ids'] ...without logging someone in.

    So, to clarify my question, I want to know how to get the $_SESSION['_amember_user'] and $_SESSION['_amember_product_ids'] objects(via php only..no forms) knowing the login name and password.
  3. grantswaim

    grantswaim New Member

    Joined:
    Mar 16, 2008
    Messages:
    109
    Amadeus,

    I am not a code monkey and can't directly help you; however, I can point you to a resource. You should take a look at the Customization Section towards the bottom of this page. It discusses the best way to integrate aMember to your site.
  4. amadeus

    amadeus Member

    Joined:
    Jan 16, 2009
    Messages:
    42
    Yea -- I looked through all of those and that's where I found those variables I put in bold (above).

    However, nothing in there explains how you would get information from the database without logging in "traditionally". I want to use this system, but it's not for a website based product, so I need a way of getting information about users more directly.

    Once I can get my hands on those variables above (or similar), then the rest I can do easily.

    Or ...if there was an amember utility for parsing the 'data' field of the database ..that would also be uber. Then, I could just use MySQL commands for everything I need to do ..and use use amember for processing payments/subscriptions/etc.
  5. grantswaim

    grantswaim New Member

    Joined:
    Mar 16, 2008
    Messages:
    109
    I am not sure how you are trying to implement this on your site, but don't forget the core feature of aMember which is to control the access to directories.
  6. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    have a look:
    http://www.php.net/manual/function.unserialize.php
  7. amadeus

    amadeus Member

    Joined:
    Jan 16, 2009
    Messages:
    42
    Alexander,

    Thanks for that! Utilizing that could make my transition easier since it would mean less for me to change on my end.

    However, my friend is giving me a hard time saying that it should be trivial to use this software to do what I want to do WITHOUT using the 'data' field (ie, similar to my original question.) Is there a method for doing that at all ...or, would I basically need the source to Login.php to do it?
  8. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    First, if you use php, better way is to use php_include protection to protect your script
    http://manual.amember.com/PHP_Include
    This way script can be available only after login and all session vars will be set in your script.

    Then you can use this simple script to query payments data from amember database:
    Code:
    <?
    // Input vars: 
    $login = $_GET['login'];
    $pass = $_GET['pass'];
    include "/full/path/to/amember/config.inc.php";
    $member_id='';
    $payments = array();
    if($db->check_login($login, $pass, $member_id)){
      $db->get_user($member_id);  // $user - associative array of user info; 
      foreach($db->get_user_payments($member_id, 1) as $p){
       $payments[] = $p; 
      }
      /// Payments - array of all completed payments (active/expired)
    }else{
      die('User not forund');
    }
    
    ?>
    
  9. amadeus

    amadeus Member

    Joined:
    Jan 16, 2009
    Messages:
    42
    Now that is a beautiful answer. :)

    You might want to update the wiki to include check_login(). (Perhaps this page: http://manual.amember.com/Using_site.inc.php_and_hooks?)



    Oh -- and, by the way, the php function var_dump() is a beautiful thing when you're working with arrays that you didn't design yourself ..haha.

Share This Page