function setupConection($client_id, $client_secret)
 {
     Podio::setup($this->client_id, $this->client_secret);
     try {
         Podio::authenticate('app', array('app_id' => $this->app_id, 'app_token' => $this->app_token));
     } catch (PodioError $e) {
     }
 }
function header_wppo()
{
    $podio_pass_var = get_option('wppo_podio_pass_var');
    // Load Podio lib
    require_once dirname(__FILE__) . '/_/Podio/PodioAPI.php';
    // Setup client
    $client_id = $podio_pass_var['client_id'];
    $client_secret = $podio_pass_var['client_secret'];
    Podio::setup($client_id, $client_secret);
    // Obtain access token using authorization code from the first step of the authentication flow
    // Podio::authenticate('authorization_code', array('code' => $_GET['code'], 'redirect_uri' => $redirect_uri));
    // Alternatively you can supply a username and password directly. E.g.:
    // It wasn't there, so regenerate the data and save the transient
    $username = $podio_pass_var['user'];
    $password = $podio_pass_var['password'];
    try {
        Podio::authenticate('password', array('username' => $username, 'password' => $password));
        // Authentication was a success, now you can start making API calls.
    } catch (PodioError $e) {
        // Something went wrong. Examine $e->body['error_description'] for a description of the error.
    }
}
Exemple #3
1
<?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);
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;
}
 /**
  * @see https://developers.podio.com/doc/organizations/end-organization-membership-50689
  */
 public static function delete($org_id, $user_id)
 {
     return Podio::delete("/org/{$org_id}/member/{$user_id}");
 }
 /**
  * @see https://developers.podio.com/doc/organizations/update-organization-22386
  */
 public static function update($org_id, $attributes = array())
 {
     return Podio::put("/org/{$org_id}", $attributes);
 }
 public function test()
 {
     try {
         \Podio::setup(Config::get('podio.client_id'), Config::get('podio.client_secret'));
         \Podio::authenticate_with_app(Config::get('podio.post_app_id'), Config::get('podio.post_app_token'));
     } catch (\PodioError $pe) {
         return $pe->getMessage();
     }
 }
function authorize()
{
    Podio::setup(CLIENT_ID, CLIENT_SECRET, array("session_manager" => "PodioSession"));
    if (Podio::is_authenticated()) {
        echo "already logged in";
    } else {
        try {
            Podio::authenticate_with_password('*****@*****.**', '1Animation2');
            // Authentication was a success, now you can start making API calls.
        } catch (PodioError $e) {
            // Something went wrong. Examine $e->body['error_description'] for a description of the error.
        }
    }
}
 /**
  * @see https://developers.podio.com/doc/comments/update-a-comment-22346
  */
 public static function update($comment_id, $attributes = array())
 {
     return Podio::put("/comment/{$comment_id}", $attributes);
 }
 /**
  * @see https://developers.podio.com/doc/notifications/un-star-notification-295911
  */
 public static function unstar($notification_id)
 {
     return Podio::delete("/notification/{$notification_id}/star");
 }
Exemple #11
0
 public static function shutdown()
 {
     // Write any new access and refresh tokens to session.
     if (self::$session_manager) {
         self::$session_manager->set(self::$oauth, self::$auth_type);
     }
     // Log api call times if debugging
     if (self::$debug && self::$logger) {
         $timestamp = gmdate('Y-m-d H:i:s');
         $count = sizeof(self::$logger->call_log);
         $duration = 0;
         if (self::$logger->call_log) {
             foreach (self::$logger->call_log as $val) {
                 $duration += $val;
             }
         }
         $text = "\n{$timestamp} Performed {$count} request(s) in {$duration} seconds\n";
         if (self::$debug === 'file') {
             if (!self::$logger) {
                 self::$logger = new PodioLogger();
             }
             self::$logger->log($text);
         } elseif (self::$debug === 'stdout' && php_sapi_name() === 'cli') {
             print $text;
         }
     }
 }
 /**
  * @see https://developers.podio.com/doc/calendar/get-item-field-calendar-as-ical-10195681
  */
 public static function ical_field($item_id, $field_id)
 {
     return Podio::get("/calendar/item/{$item_id}/field/{$field_id}/ics/")->body;
 }
Exemple #13
0
 /**
  * @see https://developers.podio.com/doc/tasks/update-task-private-22434
  */
 public function update_private($private_flag, $options = array())
 {
     $url = Podio::url_with_options("/task/{$this->id}/private", $options);
     return Podio::put($url, array('private' => $private_flag))->body;
 }
Exemple #14
0
 /**
  * @see https://developers.podio.com/doc/ratings/remove-rating-22342
  */
 public static function delete($ref_type, $ref_id, $rating_type)
 {
     return Podio::delete("/rating/{$ref_type}/{$ref_id}/{$rating_type}");
 }
 /**
  * @see https://developers.podio.com/doc/space-members/add-member-to-space-1066259
  */
 public static function add($space_id, $attributes = array())
 {
     return Podio::post("/space/{$space_id}/member/", $attributes);
 }
Exemple #16
0
 /**
  * @see https://developers.podio.com/doc/embeds/add-an-embed-726483
  */
 public static function create($attributes = array())
 {
     return self::member(Podio::post("/embed/", $attributes));
 }
// a page is refreshed. It is enabled by default.
// If you open lib/PodioSession.php you can see how simple the
// session manager is. It just has get, set and destroy methods.
// You can use the Podio::is_authenticated() method to check if
// there is a stored access token already present:
Podio::setup(CLIENT_ID, CLIENT_SECRET);
if (Podio::is_authenticated()) {
    // There is already authentication present. We can make API
    // calls without authenticating again:
    $item = PodioItem::get(YOUR_ITEM_ID);
} else {
    // No authentication present. We have to authentication
    // before making API calls:
    Podio::authenticate('app', array('app_id' => YOUR_APP_ID, 'app_token' => YOUR_APP_TOKEN));
    $item = PodioItem::get(YOUR_ITEM_ID);
}
// The downside of the built-in session manager is that it just
// stores the access tokens in the $_SESSION. This means that you
// will have to re-authenticate a user each time their close their browser
// Often you will want to persist the access tokens for a longer period.
// To do so you can implement your own session manager. All you need
// is to create a class that implements the same get, set and destroy methods.
// Then you can store the access tokens in your database or whereever.
// When doing the client setup all you need to pass in the name of your session manager
// class as an option and it will be used instead of the built-in one.
// For example if your session manager class is called 'MySessionManager'
Podio::setup(CLIENT_ID, CLIENT_SECRET, array('session_manager' => 'MySessionManager'));
// If the built-in session manager is causing you trouble you can disable it.
// This can be useful during development to make sure no stale access tokens are stored.
Podio::setup(CLIENT_ID, CLIENT_SECRET, array());
Exemple #18
0
 /**
  * Activate app in space. Only applicable to Platform
  */
 public static function activate_for_space($app_id, $space_id, $attributes = array())
 {
     return Podio::put("/app/{$app_id}/activate/{$space_id}", $attributes);
 }
 /**
  * @see https://developers.podio.com/doc/applications/delete-app-field-22355
  */
 public static function delete($app_id, $field_id, $attributes = array())
 {
     $body = Podio::delete("/app/{$app_id}/field/{$field_id}", $attributes)->json_body();
     return $body['revision'];
 }
 /**
  * @see https://developers.podio.com/doc/tags/get-objects-on-organization-with-tag-48478
  */
 public static function get_for_org($org_id, $attributes = array())
 {
     return self::listing(Podio::get("/tag/org/{$org_id}/search/", $attributes));
 }
 /**
  * @see https://developers.podio.com/doc/tasks/get-task-summary-for-reference-1657980
  */
 public static function get_summary_for($ref_type, $ref_id, $attributes = array())
 {
     $result = Podio::get("/task/{$ref_type}/{$ref_id}/summary", $attributes)->json_body();
     $result['overdue']['tasks'] = self::listing($result['overdue']['tasks']);
     $result['today']['tasks'] = self::listing($result['today']['tasks']);
     $result['other']['tasks'] = self::listing($result['other']['tasks']);
     return $result;
 }
Exemple #22
0
 /**
  * @see https://developers.podio.com/doc/spaces/delete-space-22417
  */
 public static function delete($space_id, $attributes = array())
 {
     return Podio::delete("/space/{$space_id}");
 }
 /**
  * @see https://developers.podio.com/doc/recurrence/delete-recurrence-3349970
  */
 public static function delete($ref_type, $ref_id)
 {
     return Podio::delete("/recurrence/{$ref_type}/{$ref_id}");
 }
<head>
  <title>Username and Password authentication example</title>
</head>
<body>
<?php 
// Include the config file and the Podio library
require_once 'config.php';
require_once '../PodioAPI.php';
// Setup the API client reference. Client ID and Client Secrets are defined
// as constants in config.php
Podio::setup(CLIENT_ID, CLIENT_SECRET);
// Use Podio::is_authenticated() to check is there's already an active session.
// If there is you can make API calls right away.
if (!Podio::is_authenticated()) {
    // Authenticate using your username and password. Both are defined as constants
    // in config.php
    Podio::authenticate('password', array('username' => USERNAME, 'password' => PASSWORD));
    print "You have been authenticated. Wee!<br>";
    $access_token = Podio::$oauth->access_token;
    print "Your access token is {$access_token}<br><br>";
    print "The access token is automatically saved in a session for your convenience.<br><br>";
} else {
    print "You were already authenticated and no authentication happened. Close and reopen your browser to start over.<br><br>";
}
// Now you can start making API calls. E.g. get your user status
$status = PodioUserStatus::get();
print "Your user id is <b>{$status->user->id}</b> and you have <b>{$status->inbox_new}</b> unread messages in your inbox.<br><br>";
?>
</body>
</html>
 /**
  * @see https://developers.podio.com/doc/conversations/add-participants-384261
  */
 public static function add_participant($conversation_id, $attributes = array())
 {
     return Podio::post("/conversation/{$conversation_id}/participant/", $attributes)->json_body();
 }
 /**
  * @see https://developers.podio.com/doc/items/set-participation-7156154
  */
 public static function participation($item_id, $attributes = array())
 {
     return Podio::put("/item/{$item_id}/participation", $attributes)->json_body();
 }
Exemple #27
0
 /**
  * @see https://developers.podio.com/doc/files/delete-file-22453
  */
 public static function delete($file_id)
 {
     return Podio::delete("/file/{$file_id}");
 }
Exemple #28
0
 /**
  * @see https://developers.podio.com/doc/voting/get-list-of-users-with-votes-117729546
  */
 public static function get_list_of_users_with_votes($item_id, $voting_id)
 {
     return Podio::get("/voting/item/{$item_id}/voting/{$voting_id}/user")->json_body();
 }
Exemple #29
0
 /**
  * @see https://developers.podio.com/doc/items/revert-to-revision-194362682
  */
 public static function revert_to_revision($item_id, $revision, $attributes = array())
 {
     return Podio::post("/item/{$item_id}/revision/{$revision}/revert_to", $attributes);
 }
 /**
  * @see https://developers.podio.com/doc/notifications/get-notifications-290777
  */
 public static function get_all($attributes = array())
 {
     return self::listing(Podio::get("/notification/", $attributes));
 }