Possible Cross Domain Product Check

Discussion in 'aMember Pro v.4' started by future, Jul 6, 2012.

  1. future

    future New Member

    Joined:
    Jun 20, 2010
    Messages:
    8
    Before reading this, please know that I am not a programmer and have limited knowledge of coding :)

    SCENARIO:

    I have two domains:
    domainA.com (aMember installed in domainA.com/amember/)
    domainB.com

    I LOG IN to domainA.com normally through the amember login page.
    then I go to domainB.com and want to access a member page.

    MY SOLUTION:
    I want to set up a php file on domainA.com/check.php that checks the users products. REMEMBER that the user is already logged in, so we are not relogging in. The php file looks somewhat like this:

    //CHECK.PHP
    $activeProducts = array(8);
    foreach (Am_Di::getInstance()->user->getActiveProducts() as $product) {
    if (in_array($product->pk(), $activeProducts)) {
    echo "TRUE";
    }
    }

    Then when I am on domainB.com i want to have a php file check for a html response that points to http://domainA.com/check.php to see if it's "TRUE"

    WHAT I NEED HELP WITH:
    Finishing the check.php file!! I don't know how I can "plug" into any amember functions without throwing errors. I know when I place that code in the _top.phtml file in amember/application/default/views and use the regular login script, I have it working, but i need a stand alone file without any other content that can be called from an outside domain.
  2. future

    future New Member

    Joined:
    Jun 20, 2010
    Messages:
    8
    Hi ALL... I answered my own question. Just read the Lite API documentation:

    //CHECK.PHP​
    include("library/Am/Lite.php");
    //print_r(Am_Lite::getInstance()->getUser());
    //print_r(Am_Lite::getInstance()->getProducts());
    print_r(Am_Lite::getInstance()->haveSubscriptions(8) );
    print_r(Am_Lite::getInstance()->getName());

    and altered the .htaccess to allow this file
  3. future

    future New Member

    Joined:
    Jun 20, 2010
    Messages:
    8
    Hit a brick wall! I guess my limited knowledge of programming/server behaviour let be to a dead end :(

    Any cross domain calls (with cURL) I make to aMember functions result in the script not firing.

    I have discovered the REST api, but its not exactly what I want.

    I need to make a call to aMemember from an external Domain and find out if there is an active login, and then what product ID i have.

    The REST api, requires me to log in again, which is NOT what I want.

    Is there any way I can have what I want???

    PLEASE HELP :)

    If I can't, is there a REST api call that I can make that checks if a user has a specific product, and not justa list of their products? I know I can parse the list, but I was hoping for a more cleaner approach.

    Thank you in advance.

Share This Page