pHp examples

Discussion in 'aMember Pro v.4' started by kulnor, Dec 18, 2011.

  1. kulnor

    kulnor New Member

    Joined:
    Nov 27, 2011
    Messages:
    5
    Is there a good place to look for sample pHp for 4.x?
    Just getting started and trying to get display the current logged in user id using code below
    Code:
    
    <?php
    include_once('../amember/bootstrap.php');
    echo Am_Di::getInstance()->authUser->getUserId();
    ?>
    
    
    but getting:

    Code:
    Logged in as jdoe. Logout
    exception 'Zend_Controller_Router_Exception' with message 'Route default is not defined' in /Library/WebServer/Documents/openmetadata/amember/library/Zend/Controller/Router/Rewrite.php:318 Stack trace: #0
    /Library/WebServer/Documents/openmetadata/amember/library/Zend/Controller/Router/Rewrite.php(464): Zend_Controller_Router_Rewrite->getRoute('default') #1
    /Library/WebServer/Documents/openmetadata/amember/library/Zend/Controller/Action/Helper/Url.php(99): Zend_Controller_Router_Rewrite->assemble(Array, 'default', true, true) #2
    /Library/WebServer/Documents/openmetadata/amember/library/Zend/Navigation/Page/Mvc.php(204): Zend_Controller_Action_Helper_Url->url(Array, 'default', true) #3
    /Library/WebServer/Documents/openmetadata/amember/library/Zend/View/Helper/Navigation/Menu.php(233): Zend_Navigation_Page_Mvc->getHref() #4
    /Library/WebServer/Documents/openmetadata/amember/library/Am/View/Helper/Menu.php(197): Zend_View_Helper_Navigation_Menu->htmlify(Object(Zend_Navigation_Page_Mvc)) #5
    /Library/WebServer/Documents/openmetadata/amember/library/Am/View/Helper/Menu.php(178): Am_View_Helper_Menu->htmlify(Object(Zend_Navigation_Page_Mvc)) #6
    /Library/WebServer/Documents/openmetadata/amember/library/Zend/View/Helper/Navigation/Menu.php(505): Am_View_Helper_Menu->_renderMenu(Object(Am_Navigation_User), '', '', 0, 1,
    false) #7
    /Library/WebServer/Documents/openmetadata/amember/application/default/views/member/_menu.phtml(21): Zend_View_Helper_Navigation_Menu->renderMenu(Object(Am_Navigation_User), Array) #8
    /Library/WebServer/Documents/openmetadata/amember/application/default/views/_top.phtml(10): include('/Library/WebSer...') #9
    /Library/WebServer/Documents/openmetadata/amember/application/default/views/layout.phtml(27): include('/Library/WebSer...') #10
    /Library/WebServer/Documents/openmetadata/amember/library/Am/View.php(352): include('/Library/WebSer...') #11
    /Library/WebServer/Documents/openmetadata/amember/library/Zend/View/Abstract.php(888): Am_View->_run('/Library/WebSer...') #12
    /Library/WebServer/Documents/openmetadata/amember/library/Am/View.php(326): Zend_View_Abstract->render('error.phtml') #13
    /Library/WebServer/Documents/openmetadata/amember/library/Am/App.php(1623): Am_View->display('error.phtml') #14
    [internal function]: Am_App->__exception(Object(InvalidArgumentException)) #15
    {main} thrown within the exception handler. Message: Route default is not defined on line 318
    
  2. s_teachings

    s_teachings Member

    Joined:
    Jul 24, 2008
    Messages:
    32
    There are some example in the API section of the online docs. For example,

    http://www.amember.com/docs/API/Authentication

    shows the following code:

    PHP:
    Am_Di::getInstance()->authUser->getUser(); // returns User object or null
    Am_Di::getInstance()->authUser->getUserId() // returns user_id or null
    $result Am_Di::getInstance()->authUser->login('login''password''11.22.33.44');
    echo 
    $result->isValid() ? "OK" : ("failed: " $result->getMessage());

    Am_Di::getInstance()->authUser->logout();
    Would be nice to have more examples in the documentation though.
  3. crogue

    crogue New Member

    Joined:
    Dec 17, 2011
    Messages:
    13
  4. kulnor

    kulnor New Member

    Joined:
    Nov 27, 2011
    Messages:
    5
    Am_Lite works great.
    Thanks,
    *K

Share This Page