setup() public static method

public static setup ( $client_id, $client_secret, $options = ['session_manager' => null, 'curl_options' => []] )
コード例 #1
3
 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) {
     }
 }
コード例 #2
1
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;
}
コード例 #3
1
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.
    }
}
コード例 #4
1
ファイル: test.php プロジェクト: 2UP/podio-doc-to-pdf
<?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);
コード例 #5
0
 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();
     }
 }
コード例 #6
0
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.
        }
    }
}
* Open this new config.php and fill in your client id, client secret and your Podio username and password
* Run this file in your browser.
*/
?>
<html>
<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();
コード例 #8
0
// 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());
コード例 #9
0
ファイル: index.php プロジェクト: jneumann/home-page
    echo $v->text;
    if (isset($v->entities->urls['0']->url)) {
        echo "</a>";
    }
    echo "</div>";
    echo "</div>";
}
?>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-md-6">
					<h1>Podio</h1>
					<?php 
Podio::setup($config['podio']['client-id'], $config['podio']['client-secret']);
Podio::authenticate_with_app($config['podio']['ww-app-id'], $config['podio']['ww-app-secret']);
$ww = PodioItem::filter($config['podio']['ww-app-id']);
foreach ($ww as $week) {
    if ($week->title == 'Jake Neumann') {
        $week_start = $week->fields['1']->values['start'];
        if (time() - 60 * 60 * 24 * 7 < strtotime($week_start->format('Y-m-d H:i:s'))) {
            // var_dump( $week->fields );
            foreach ((array) $week->fields as $week) {
                foreach ((array) $week as $day) {
                    if (is_object($day) && $day->type == 'app') {
                        echo '<h4>' . $day->label . '</h4>';
                        foreach ($day->values as $proj) {
                            echo '<a href="' . $proj->link . '" target="_blank">';
                            echo $proj->title;
                            echo '</a>';