PHP-SDK

Getting started

You can find our PHP SDK on github.

Installation

composer require app-arena/php-sdk

Usage

Use the Composer Autoloader to start using the App-Manager

// In your index.php
define("ROOT_PATH", realpath(dirname(__FILE__)));
require ROOT_PATH . '/vendor/autoload.php';

$m_id = 123; // Set your app-arena Model ID here

// Clear the cache before, requestion Instance in for each
$am = new \AppManager\AppManager(
    $m_id,
    array(
        "root_path" => ROOT_PATH,
        "cache_dir" => "/var/cache"
    )
);
// Get all necessary instance information to start working
$config = $am->getConfigs();
$translation = $am->getTranslations();
$info = $am->getInfos();

Now the connection is build up and you can start using you App-Instance. The App-Manager SDK automatically tries to get your Instance ID (i_id) from GET-Parameters or from Cookies. So your Url should be something like this:

http://www.domainofmyapp.com/mypage.php?i_id=1234

Methods

Method Description Parameters Response
addParams($params) This will add parameters to the smartLink Url. These parameters will be available as GET-Parameters, when a user* clicks on the smartLink. The parameters will be available as GET parameters as well in the facebook page tab* or within an iframe array $params Array of parameters which should be passed through  
cleanCache() Cleans the cache, so that a fresh API call will be done    
getBaseUrl() Returns the BaseUrl your Sharing Url is generated with. By default it will use the currently used domain   string
getBrowser() Returns user browser information   array
getBrowserName() Returns the users browser name   string
getBrowserVersion() Returns user browser major version   int
getConfig($config_id, $attr = “value”) Returns the value of a config value String $config_id Config identifier to get the data for String string array $attr Attribute or Attributes which should be returned
getConfigs() Returns all Config Elements of the current instance as array   array
getCssHelper() (DEPRECATED) Returns CSS Helper object to compile and concatenate Less, CSS and Config-Type (CSS) values   CSS
getCssFiles($css_config) Returns CSS Helper object to compile and concatenate Less, CSS and Config-Type (CSS) values array $css_config Array to define the compilation process (@see CSS Config. ) array List of compiled CSS file path’s
getDevice() Returns user device information   array
getDeviceType() Returns the device type of the current device mobile, tablet, desktop   string
getEnvironment() Returns if the app currently running on a website, facebook or direct website means the app is embedded via iframe to a website facebook means the app is embedded in a facebook page tab direct means the app is being accessed directly without iframe embed   string
getFacebookInfo() Returns all available Facebook information, like currently used fanpage and canvas information.    
getIId() Returns the currently used Instance ID   int
getInfo($attr) Returns an attribute of the instance String $attr Attribute you want to return string
getInfos() Returns all basic information of the current instance   array
getLang() Returns the currently used Language as Language Code (e.g. de_DE, en_US, ...)   string
getMId() Returns the model ID of the currently selected instance   int
getParams() Returns all params submitted to the SmartLink before redirection   array
getTranslation($translation_id, $args = array() Returns the translation for the submitted ID String $translation_id Config identifier to get the data Array $args Array of values to replace in the translation (@see http://php.net/manual/de/function.vsprintf.php ) string
getTranslations() Returns all translations for the currently set language   array
getUrl() Returns the SmartLink Url for Sharing   string
getUrlLong() Returns the SmartLink Url without Url Shortener bool $shorten Shorten URL using smartl.ink string
renderSharePage ($debug = false) Renders the complete HTML of the Share page including all meta tags and redirection. bool $debug - Show debug information on the page? string
setBaseUrl($base_url) Sets a new base url for your sharing links (->getUrl()). string $base_url New base url void
setFilename($filename) Sets the filename for the SmartLink (default: smartlink.php) string $filename void
setLang($lang) Sets a new language for the current instance string $lang 5 char Language Code,e .g. de_DE  
setMeta($meta) Sets the meta data for SmartLink Share page. All key value pairs will be generated as meta information into the head of the share page. The array keys title, desc, image are the most important. The array values can be Strings or config identifiers of the instance array $meta (see description) array
setParams($params) This will reset all parameters of the smartLink Url. These parameters will be available as GET-Parameters, when a user* clicks on the smartLink. The parameters will be available as GET parameters as well in the facebook page tab* or within an iframe array $params Array of parameters which should be passed through