• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Error when try to create my own api.

#1
Hi,

I've try to create my own api (bridge) to work with XenForo core, here is my demo api.php code:

PHP:
<?php
    error_reporting(-1);
    ini_set("display_errors", 1);   
    /**
    *** INIT XF
    **/
    define('SCRIPT_ROOT', empty($_SERVER['SCRIPT_FILENAME']) ? '../' : dirname(dirname($_SERVER['SCRIPT_FILENAME'])).'/');
    require_once(SCRIPT_ROOT. '/library/XenForo/Autoloader.php');
    XenForo_Autoloader::getInstance()->setupAutoloader(SCRIPT_ROOT. '/library');
    XenForo_Application::initialize(SCRIPT_ROOT . '/library', SCRIPT_ROOT);
    XenForo_Application::set('page_start_time', microtime(TRUE));

    $deps = new XenForo_Dependencies_Public();
    $deps->preLoadData();
    exit();
?>
This is my forum struct:

xf_dir
-------index.php
-------api/
-----------api.php

And I always see this error:
An exception occurred: cache_dir must be a directory in /var/www/mysite.com/library/Zend/Cache.php on line 209

Zend_Cache::throwException() in /var/www/mysite.com/library/Zend/Cache/Backend/File.php at line 154
Zend_Cache_Backend_File->setCacheDir() in /var/www/mysite.com/library/Zend/Cache/Backend/File.php at line 121
Zend_Cache_Backend_File->__construct() in /var/www/mysite.com/library/Zend/Cache.php at line 153
Zend_Cache::_makeBackend() in /var/www/mysite.com/library/Zend/Cache.php at line 94
Zend_Cache::factory() in /var/www/mysite.com/library/XenForo/Application.php at line 753
XenForo_Application->loadCache()
call_user_func_array() in /var/www/mysite.com/library/XenForo/Application.php at line 960
XenForo_Application->lazyLoad() in /var/www/mysite.com/library/XenForo/Application.php at line 991
XenForo_Application::get() in /var/www/mysite.com/library/XenForo/Application.php at line 1601
XenForo_Application::getCache() in /var/www/mysite.com/library/XenForo/Model.php at line 146
XenForo_Model->_getCache() in /var/www/mysite.com/library/XenForo/Model/DataRegistry.php at line 81
XenForo_Model_DataRegistry->getMulti() in /var/www/mysite.com/library/XenForo/Dependencies/Abstract.php at line 147
XenForo_Dependencies_Abstract->preLoadData() in /var/www/mysite.com/api/api.php at line 14
Any idea? Look like the cache_dir is wrong here, but I don't know where to fix. Thanks