Non-Import Batching

Discussion in 'Integration' started by keithdturner, Apr 20, 2005.

  1. keithdturner

    keithdturner Guest

    Hi,

    I'm new to this application and have been asked to build a tool to help our client batch upload from a spreadsheet. I'm looking for advise and additional documentation.

    I can easily build an Excel/VBA application that validates records and uses form posts to upload data. As they are automatically generating the usernames, database unique constraints should not be a problem. It would be ideal to return the member_id field to add to this tool, but that's not needed for the first go round.

    I see that I need to create a server-side "catch" script - we are trying to avoid having the client do anything in the aMember Admin online site, so file uploads (and using the import function, darn it) is not an option, so a series of posts makes more sense.

    It looks like the functionality of the signup.php script and perhaps the import.php script will have to be duplicated in the server-side "catch" script.

    I'm not an experienced php programmer, but have used it a little. Any advice given as to how to hook into the "aMember API for add user" as suggested by the response to a support ticket and pointers to scripting documentation for aMember (as compared the the help files which seem to only deal with its usage) would be greately appreciated.

    Thanks,

    Keith
    ps Admins - this is the second time I wrote this - the first time I pressed "Preview Post" and it took me to a log in screen, which then lost the entire contents. I'm saving a text back up this time ;]
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Unfortunately, there is no API description for this case.
    You may have a look to signup.php to see example how it should be handled in details.

    In short, it works this way (put file to amember/ folder):
    PHP:
    <?php
    require_once 'config.inc.php';

    $vars get_input_vars();
    /* check if username is exists */
    $member_id $db->check_uniq_login($vars['login'], $vars['email'], $vars['pass0'], 1);
    if (
    $member_id 0) {
        
    $member_id $db->add_pending_user($vars); // add member record
       
    if (!$member_id) die("Cannot add user");
    } else { 
       
    // existing user found, his id in $member_id - your handling here
    }

    /* add payment record */
    $payment = array(
                    
    'product_id'  => $vars['product_id'], // numeric
                    
    'begin_date'  => $vars['begin_date'], //yyyy-mm-dd
                    
    'expire_date' => $vars['expire_date'], //yyyy-mm-dd
                    
    'paysys_id'   => 'manual'// for example
                    
    'amount'      => $vars['manual'], //decimal 10.2
                    
    'receipt_id'  => $vars['receipt_id'],
                    
    'member_id'   => $member_id,
                    
    'completed'   => // payment will be marked as paid at creation
    );
    $payment_id $db->add_payment($payment);
    if (!
    $payment_id) die("cannot add payment: $payment_id");

    ?>

Share This Page