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';

// Add App-Arena App-Manager
$am = new \AppArena\AppManager(
    array(
        "projectId" => 123, // Add your project ID here
        "root_path" => ROOT_PATH,
        "cache" => ["dir" => "/var/cache"],
        'apikey' => "ABCDEFGHIJKLMNOPQRSTUVW" // Add you API key here
    )
);
// Get all necessary instance information to start working
$configs      = $am->getApp()->getConfigs();
$translations = $am->getApp()->getTranslations();
$info         = $am->getApp()->getInfos();

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

http://www.domainofmyapp.com/mypage.php?appId=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    
getApp() Returns the currently used App object   int
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
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.    
getLang() Returns the currently used Language as Language Code (e.g. de_DE, en_US, ...)   string
getParams() Returns all params submitted to the SmartLink before redirection   array
getProjectId() Returns the project ID of the currently selected app   int
getOperatingSystem() Returns the operating system of the current user   string
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  

The app object

You can use the app object to retrieve config-values, translations and basic information about an app. The PHP SDK tries to get the current app ID from a REQUEST-Parameter or a previous set cookie.

To get the app-object call

// In your index.php
$app = $am->getApp();
$appId = $app->getId();
$appConfigs = $app->getConfigs();
$appTranslations = $app->getTranslations();
$appInfo = $appInfos();
Method Description Parameters Response
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
getId() Returns the currently used App 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
getLanguages() Returns all available and activated languages of the app   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
isAdmin($projectSecret) Returns if the current request contains admin authentication information (GET-params) String $projectSecret The project secret to validate the Hash bool