public static function setup($client_id, $client_secret, $options = array('session_manager' => null, 'curl_options' => array()))
{
// Setup client info
self::$client_id = $client_id;
self::$client_secret = $client_secret;
// Setup curl
self::$url = empty($options['api_url']) ? 'https://api.podio.com:443' : $options['api_url'];
self::$debug = self::$debug ? self::$debug : false;
self::$ch = curl_init();
self::$headers = array('Accept' => 'application/json');
curl_setopt(self::$ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt(self::$ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt(self::$ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt(self::$ch, CURLOPT_USERAGENT, 'Podio PHP Client/' . self::VERSION);
curl_setopt(self::$ch, CURLOPT_HEADER, true);
curl_setopt(self::$ch, CURLINFO_HEADER_OUT, true);
//Update CA root certificates - require: https://github.com/Kdyby/CurlCaBundle
if (class_exists('\\Kdyby\\CurlCaBundle\\CertificateHelper')) {
\Kdyby\CurlCaBundle\CertificateHelper::setCurlCaInfo(self::$ch);
}
if ($options && !empty($options['curl_options'])) {
curl_setopt_array(self::$ch, $options['curl_options']);
}
self::$session_manager = null;
if ($options && !empty($options['session_manager'])) {
if (is_string($options['session_manager']) && class_exists($options['session_manager'])) {
self::$session_manager = new $options['session_manager']();
} else {
if (is_object($options['session_manager']) && method_exists($options['session_manager'], 'get') && method_exists($options['session_manager'], 'set')) {
self::$session_manager = $options['session_manager'];
}
}
if (self::$session_manager) {
self::$oauth = self::$session_manager->get();
}
}
// Register shutdown function for debugging and session management
register_shutdown_function('Podio::shutdown');
}