11 Replies Latest reply on May 23, 2011 5:39 PM by Seglespaan

    J-amfphp

    Seglespaan

      Hi,

       

      anyone know how to use j-amfphp in joomla?

       

      I've been using amfphp for a while now but want to try and integrate my app into a flex build. However I can't get the service browser in root/amfphp to recognise the services in the root/plugins/j-amfphp folder.

       

      I've gone through this guide with a fine tooth combe possibly a thousand times to no avail.

       

      http://figo.tandolin.co.za/adobe-air/how-to-use-jamfphp-for-joomla-remoting.htm

       

      any help would be much appreciated.

       

      Tim

        • 1. Re: J-amfphp
          Jeff Gietz Level 1

          Hey something I might be able to help with, I think I initially followed that tutorial.

          After you have installed the plugin your classes need to be stored in root/plugins/j-amfphp/itemname/classname.php

          Then you gain the assesability of using Joomla! capabilities for your data, here is an example:

           

          test.php

           

          class test

          {

               function getData()

               {

                    /*Get database object (Rather than requiring a seperate MYSQL connection*/

                    $database = JFactory::getDBO();

                    /*Apply query (#__ is your database prefix which is normally jos_)*/

                    $database->setQuery( "SELECT * FROM #__tablename" );

                    /*Activate query*/

                    $results = $database->loadObjectList();

                    return $results;

               }

          }

          • 2. Re: J-amfphp
            Seglespaan Level 1

            How do I access this from within flex as the gateway I would normally point

            to is in root/amfphp/

             

            Also is it possible to test this is working using the service browser??

             

            Thanks

             

            Tim

            • 3. Re: J-amfphp
              Jeff Gietz Level 1

              When J-amfphp is installed it creates the gateway file in root/amfphp/gateway.php (assuming thats where your Joomla! build is).

              You can also download the latest version of AMFPHP from sourceforge and copy the browser folder from there to root/amf/gateway so you have root/amf/gateway/browser

              Then navigate to the site/amfphp/browser in your browser. That guide you linked was very good, there is also a book I had which helped a bit called "Joomla! with Flash" by Suhreed Sarkar, there is only one chapter on the subject but it was helpful.

              • 4. Re: J-amfphp
                Seglespaan Level 1

                I think I'm actually going to spew over this.

                 

                After much messing about I uninstalled and re-installed the J-amfphp plugin for Joomla.

                 

                I can now see my class in the service browser, however when I call my method I get an empty user object returned even though I'm logged in.

                 

                I've written a simple php script and when I navigate to it in the browser I can echo "user is logged in" using

                 

                $user = JFactory::getUser();

                 

                if($user->id){

                     echo "user is logged in";

                }else{

                     echo "user is not logged in";

                }

                 

                 

                however when I try an implement the same functionality in my class it doesn't work and always returns guest 1.

                 

                Also if I use

                 

                $user = JFactory::getUser(68);

                 

                retrun $user;

                 

                I can then see a complete user object populated with my data, can anyone tell me why I am not able to us $user = JFactory::getUser(); to see if a user is logged in and if so return their data?

                 

                Thanks

                 

                Tim

                • 5. Re: J-amfphp
                  Jeff Gietz Level 1

                  If you copied the browser from a seperatly downloaded version of amfphp as per the instructions on that link, you won't need to login. If you do want to see if a user is logged into Joomla you can use this

                   

                  $checkuser = JFactory::getUser();
                  if ($checkuser->get('gid')>0){
                  echo "logged in";
                  }

                  • 6. Re: J-amfphp
                    Seglespaan Level 1

                    yeah I copied it from a seperate download of teh latest amfphp.

                     

                    if I use

                     

                    $checkuser = JFactory::getUser();
                    if ($checkuser->get('gid')>0){
                         echo "logged in";
                    }

                     

                    in a file called test.php in my site root it echo's "logged_in"

                     

                    if I then try and call a method called test_get_user_logged_in which sits in root/j-amfphp/test.php which looks like this

                     

                    class test

                    {

                              function test_get_user_logged_in(){

                                   $checkuser = JFactory::getUser();
                                   if ($checkuser->get('gid')>0){
                                        return "logged in";
                                   }

                              }

                    }

                     

                     

                    I get a response of null,

                    • 7. Re: J-amfphp
                      Seglespaan Level 1

                      could it be something  to do with sessions?

                       

                      does flex create a different session ID?

                      • 8. Re: J-amfphp
                        Jeff Gietz Level 1

                        I added

                        if ($checkuser->get('gid')==0){
                                             return "not logged in";
                        }

                        For testing purposes and it will detect that your  not logged in. I'm going to assume that using the AMF system wouldn't  call a session id at all, as I believe that there is no way to store it  (normally it's a cookie). Have you tried doing a simplier method (like  setting a query to the db) like the one I posted, to see if everything  is working correctly first?

                         

                        Also if you want to see who is currently online you could try looking in the Joomla! core module Who's Online (mod_whosonline), but for greater details on that you need to check Joomla! docs or forums.

                        • 9. Re: J-amfphp
                          Seglespaan Level 1

                          See that's the bit i just don't get, as everything does seem to be working.

                           

                          when I use

                           

                          $user = JFactory::getUser(68);

                          return $user;

                           

                          The object returned has my username, email, id, gid etc all populated as expected and guest is set to null.

                           

                          So if I know the users id I can return the user object, but I will never know the user id from within my flex app until I can get $user = JFactory::getUser(); to return the user data correctly.

                           

                          I might go and have a look at the other methods you mentioned.

                           

                          Thanks for all your help.

                           

                          Tim

                          • 10. Re: J-amfphp
                            Seglespaan Level 1

                            I think it has something to do with sessions,

                             

                            when I call

                             

                            $session  =& JFactory::getSession();

                            $session_id = $session->getId();

                            return $session_id;

                             

                            my flex app returns a session_id that ends in f68d

                             

                            however when I look in the jos_sessions table I can see that the registered logged in user (me) has a session id ending in 21ea

                             

                            any idea why flex / amfphp would create an additional session?

                             

                            Tim

                            • 11. Re: J-amfphp
                              Jeff Gietz Level 1

                              No sorry I don't know why flex would call an extra session id, maybe it's being called as a seperate instance/user. If there was a way you could pull the session data from your browser to your flex program you could send it to your method.