function check_config() { global $config; Podio::$debug = true; try { Podio::setup($config['podioClientId'], $config['podioClientSecret']); } catch (PodioError $e) { show_error("Podio Authentication Failed. Please check the API key and user details."); return false; } try { Podio::authenticate('password', array('username' => $config['podioUser'], 'password' => $config['podioPassword'])); } catch (PodioError $e) { show_error("Podio Authentication Failed. Please check the API key and user details."); return false; } if (!Podio::is_authenticated()) { show_error("Podio Authentication Failed. Please check the API key and user details."); return false; } return true; }
<?php require 'vendor/autoload.php'; require_once 'app_setting.inc.php'; use ZendService\LiveDocx\MailMerge; error_log("validate triggerd"); // Setup client Podio::setup($client_id, $client_secret); // Turn on debugging Podio::$debug = true; // Authenticate the app Podio::authenticate('app', array('app_id' => $app_id, 'app_token' => $app_token)); switch ($_POST['type']) { case 'hook.verify': // Validate the webhook PodioHook::validate($_POST['hook_id'], array('code' => $_POST['code'])); case 'item.create': $item = PodioItem::get($_POST['item_id']); $temp_array = array(); foreach ($item->files as $fs) { $temp_array[] = $fs; if ($fs->mimetype == 'application/msword') { //Get file name withour ext $no_ext = substr($fs->name, 0, strpos($fs->name, '.')); //Upload file to our server $fl = PodioFile::get($fs->file_id); $fc = $fl->get_raw(); file_put_contents($upload_path . $fs->name, $fc); //Part with convert files from doc(x) to pdf $mailMerge = new MailMerge(); $mailMerge->setUsername($user)->setPassword($password)->setService(MailMerge::SERVICE_FREE);
public static function setup($client_id, $client_secret, $options = array('session_manager' => 'PodioSession', '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, false); curl_setopt(self::$ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt(self::$ch, CURLOPT_USERAGENT, 'Podio PHP Client/3.0'); curl_setopt(self::$ch, CURLOPT_HEADER, true); curl_setopt(self::$ch, CURLINFO_HEADER_OUT, true); if ($options && !empty($options['curl_options'])) { curl_setopt_array(self::$ch, $options['curl_options']); } self::$session_manager = null; if ($options && !empty($options['session_manager']) && class_exists($options['session_manager'])) { self::$session_manager = new $options['session_manager'](); self::$oauth = self::$session_manager->get(); } // Register shutdown function for debugging and session management register_shutdown_function('Podio::shutdown'); }
/** * Set debug config * * @param $toggle True to enable debugging. False to disable * @param $output Output mode. Can be "stdout" or "file". Default is "stdout" */ public static function set_debug($toggle, $output = "stdout") { if ($toggle) { self::$debug = $output; } else { self::$debug = false; } }