示例#1
0
function getProjectList()
{
    try {
        $category_status_id = 62473690;
        //the category status id - need to get integer value for status
        // Pitching - 9
        // Bidding - 8
        // Planning - 1
        // Design - 2
        // Proofing - 10
        // IN REVIEW - 7
        // LEGAL REVIEW - 11
        // ON HOLD - 6
        // Development - 3
        // Complete - 4
        // Billed - 12
        // Closed - 13
        $planning_collection = PodioItem::filter(APP_ID, array('filters' => array($category_status_id => array(1)), 'limit' => 250));
        foreach ($planning_collection as $item) {
            echo 'id: ' . $item->id;
            echo '<br>';
            echo 'title: ' . $item->title;
            echo '<br>';
            //due date here retrieved using external_id
            $due_date = $item->fields["due-date"];
            $job = $item->fields["job"];
            print "Job Number " . $job->values;
            echo '<br>';
            print "This field has the external_id: " . $due_date->external_id;
            echo '<br>';
            //print "DATE HERE: " .$due_date->start;
            //print "DATE HERE: " .$due_date->start_date;
            $date = $due_date->start;
            echo date_format($date, 'Y-m-d H:i:s');
            echo '<br>';
            print "DATE HERE: " . $due_date->end->humanized_value;
            //print $field->start_date->humanized_value;
            echo '<br>';
            foreach ($item->fields as $due_date) {
                // You can now work on each individual field object:
                print "This field has the id: " . $due_date->field_id;
                print " This field has the external_id: " . $due_date->external_id;
                echo '<br>';
            }
            echo '<br>';
            echo 'GET ALL TASKS';
            echo '<br>';
            //"due_date", "created_by", "responsible", "app", "space" or "org"
            $tasks = PodioTask::get_all(array('completed' => 0, 'app' => 8060831, 'grouping' => 'due_date', 'offset' => 0, 'limit' => 50));
            foreach ($tasks as $task) {
                echo 'task id: ' . $task->task_id;
                echo '<br>';
                echo 'due_date: ' . $task->due_date;
                echo '<br>';
                echo 'due_time: ' . $task->due_time;
                echo '<br>';
                echo 'text: ' . $task->text;
                echo '<br>';
            }
        }
    } catch (Exception $e) {
        echo $e;
    }
}
<?php

// This is a list of examples on podio-php basics.
// The script is not meant to be run (you'll get errors),
// it is simply an illustration of the syntax you must use.
// The first thing you must always do is to setup the API client and authenticate:
// Setup the client. See authentication.php
Podio::setup(CLIENT_ID, CLIENT_SECRET);
// Authenticate. In this case using App Authentication, but see authenticate.php for more ways to authenticate.
// You can check if authentication has already happened with Podio::is_authenticated()
// See session-manager.php for more
if (!Podio::is_authenticated()) {
    Podio::authenticate('app', array('app_id' => YOUR_APP_ID, 'app_token' => YOUR_APP_TOKEN));
}
// You will be working with two types of methods. Direct calls to the API is made using static methods on the classes:
$task = PodioTask::get(123);
// When possible these calls will return instances of the class in question. You can then work with that object directly. Above we get an instance of the PodioTask class and we can print the task_id and the link to the task. The properties are available directly on the object:
print $task->id;
print $task->link;
// Open each class in the 'models' folder to see which properties are available for each class.
// Some properties are instances of other classes. You can see these marked as 'has_one' or 'has_many' in the constructor.
// For example PodioTask has one 'created_by' (instance of PodioByLine) and it has_many 'labels' (array of PodioTaskLabel instances):
print get_class($task->created_by);
// Will print 'PodioByLine'
// You can then drill into these relationships easily. E.g. to print the name of the author:
print $task->created_by->name;
// App items are the most complicated part of the Podio API and there are many shortcuts in the PHP library to make your life easier. See items.php for details.