We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22996
    • 15 Posts
    I have read about the moxapi.php (http://wiki.modxcms.com/index.php/MODx_site_menu_in_external_PHP_app) and have implemented the example. However, for the life of me, I still cannot get modxapi.php to work. The page seems to choke when I create the MODxAPI instance using $modx = new MODxAPI();

    I have changed the path to $path = ’http://localhost:8888/americasite/’; this is the root of the modx website which works fine

    I also changed the modxapi.php variable $_api_path = ’http://localhost:8888/americasite/’;

    I’m not sure what else to do to implement the api - i can’t even figure out what the issue is...it loads a page with nothing on it.


      • 28042 ☆ A M B ☆
      • 24,524 Posts
      I think you are mistaking a URL with a path. Usually a path is the file system path, such as /home/mydomain/public_html/americasite/...
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 22996
        • 15 Posts
        Goodness. Thank you. I added the following to get it to work:

        /Applications/MAMP/htdocs/americasite/
          • 22996
          • 15 Posts
          Ok, one more issue modxapi.

          I have a .php script and I dropped this same script into 2 different directories. The same exact .php file works in one directory and not the other.

          The script in the following path: /Applications/MAMP/htdocs/americasite/webservice/services/getuser.php works fine
          The script in the following path: /Applications/MAMP/htdocs/americasite/amfphp/services/getuser.php does not work - it creates two errors

          1. Cannot send session cache limiter - headers already sent
          2. Cannot modify header information - headers already sent

          Here is the modxapi includes I have in the beginning of my external php script:

          $base_path = ’/Applications/MAMP/htdocs/americasite/’;

          include($base_path . ’modxapi.php’);

          $modx = new MODxAPI();
          $modx->db->connect();
          $modx->getSettings();