Giter Club home page Giter Club logo

podio-php's People

Contributors

antronin avatar auchenberg avatar bajarang-agarwal avatar bbanuri avatar carlfredrikhero avatar cmchase avatar daniel-sc avatar daviferreira avatar dersam avatar dougblackjr avatar frankwong avatar haugstrup avatar hellokirk avatar houmark avatar hphuhtin avatar jakubboucek avatar jimmyt1988 avatar korushdev avatar lucasmichot avatar martin-4spaces avatar mgithens avatar mmoole avatar mrbr avatar nikolajlovenhardt avatar rafaelmb avatar rspace avatar tamasys avatar tehwebby avatar theflow avatar timosillander avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

podio-php's Issues

PodioNotFoundError on file upload with expired token

When calling PodioFile::upload and the auth token is expired, the call fails and returns an error instead of refreshing the token and performing the action like other API calls.

The error is:
PodioNotFoundError: "No matching operation could be found. Missing parameters: source."
Request URL: http://api.podio.com/file/v2/

Stack Trace:
#0 /var/www/vhosts/podioflow.com/httpdocs/podio-php-master/lib/Podio.php(240): Podio::request('POST', '/file/v2/', Array)
#1 /var/www/vhosts/podioflow.com/httpdocs/podio-php-master/lib/Podio.php(293): Podio::request('POST', '/file/v2/', Array, Array)
#2 /var/www/vhosts/podioflow.com/httpdocs/podio-php-master/models/PodioFile.php(39): Podio::post('/file/v2/', Array, Array)

Non-static Podio class

Hi there,

for more fine grained control it would good if the API could be accessed in a non-static way. Especially for unit testing/mocking this is a must.

As a first shot I created: daniel-sc@d7ca0e4

Do you think that's feasible?

greets, Daniel

Expired tokens not detected in Podio::is_authenticated()

Somewhat like the upload file bug, I am seeing random instances where a get_with_external_id call will fail with code 400 or 401 with "unauthenicated" error. This code only runs after Podio::is_authenticated() is checked for true. Then sometime later the token is refreshed before an update or item creation.

some log output :

2014-09-18 02:34:03 401 GET /item/app/9248862/external_id/[email protected]
2014-09-18 02:34:03 Reponse: {"error_parameters":{},"error_detail":null,"error_propagate":false,"request":{"url":"http://api.podio.com/item/app/9248862/external_id/[email protected]","query_string":"","method":"GET"},"error_description":"expired_token","error":"unauthorized"}

2014-09-18 02:42:04 200 POST /item/app/9248862/
2014-09-18 02:42:04 Request body: {"external_id":"[email protected]","fields":{"phone-number":"8317082022","email-

PodioItem::filter returns an empty array if the app has more than 4 items

I am trying to use PodioItem::filter to return a collection of items from an app. I tested with multiple apps in different workspaces and it's always the same: if the app contains 1 to 4 items everything works fine, but if it has 4+ items, an empty array is returned like this:

object(PodioItemCollection)[4]
public 'filtered' => null
public 'total' => null
private '__items' (PodioCollection) =>
array (size=0)
empty
private '__belongs_to' (PodioCollection) => null

The same happens when I try to limit the returned items:
PodioItem::filter( $item_id, array('limit' => 4) ); - works as expected
PodioItem::filter( $item_id, array('limit' => 5) ); - returns an empty array
Any ideas why this could be happening?

Edit: I tried adding more data to each item, and then the filter started returning an empty array for less items. At one point, when a single item contained lots of data, an empty array was returned, even when limit was set to 1. This leads me to think that the response size has something to do with it.

And some more info: I am using the latest version of the PHP library and working on localhost/WAMP.

Uncaught PodioError thrown, but status 0 and no message

Some of my Podio sync scripts suddenly stopped working. While debugging, I found out that Podio was throwing some errors, but without any details:

Fatal error: Uncaught PodioError
Request URL:
Request Body: null

I found a 400 error in my log:

2013-06-18 13:05:09 Reponse: <html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx/1.2.7</center>
</body>
</html>

Anyone experiencing the same problems?

Items: Get item values

In the Podio API documentation there is an operation called 'Get item values' https://developers.podio.com/doc/items/get-item-values-22365

I see it's missing in the Podio PHP client (or have i missed it?)

I actually want to get the field values from an item by the external id of the field. I can only find a method that needs to have the field_id. I am working on a method to do this and I thought about starting with get-item-values, that's when i noticed this operation is missing from the PHP client.

If there is already a method like Item::get_field_value_by_external_id($item_id, $field_external_id) where $field_external_id is a string. Please let me know :)

[important] Last commit broke the API client.

In Podio.php line 92

this line:

$request_data = array_merge($data, array('client_id' => self::$client_id, 'client_id' => self::$client_secret));

should be:

$request_data = array_merge($data, array('client_id' => self::$client_id, 'client_secret' => self::$client_secret));

debug mode doesn't work

Since moving from v2 to v4 I can't get debug mode to write to a log file. This is how I'm trying to do it :

require_once('podio-php-4.0.1/PodioAPI.php');
Podio::set_debug(true);

No log file gets created.

Documentation issue

$item = PodioItem::get_basic(123);
$field_id = 'money';

print $item->fields[$field_id]->currency; // E.g. "USD"
print $item->fields[$field_id]->amount; // E.g. "123.5400"
print $item->fields[$field_id]->humanized_value; E.g. "$123.54"

should be
print $item->fields[$field_id]->humanized_value(); E.g. "$123.54"

Fatal error: Class 'PodioQuestion' not found

Fatal error: Class 'PodioQuestion' not found in /Volumes/Data/Projects/podio-sync/podio/lib/PodioObject.php on line 57


Here is my code:

<?php
require_once('config.php');
require_once('podio/PodioAPI.php');

Podio::setup(CLIENT_ID, CLIENT_SECRET);

if (!Podio::is_authenticated())
{
    try {
        Podio::authenticate('app', array('app_id' => APP_ID, 'app_token' => APP_TOKEN));
    }
    catch (PodioError $e) {
        // Something went wrong. Examine $e->body['error_description'] for a description of the error.
        var_dump($e);
    }
}

// $status = PodioUserStatus::get();

// Authentication was a success, now you can start making API calls.
$task = PodioItem::get(22792939);
var_dump($task);

PHP PodioSpace.php LINE 65

URI is wrong in this function, please change from "/space/url" to "/space/top/" as per the documentation and testing code on podios site.

The function should also accomodate a limit option with a default of 6, so it should look like "/space/top/?limit={$limit}"

Thanks.

Rate Limit Bug

When requesting the Rate Limit / Rate Limit Remaining, when no request has been done yet, the library will crash. There needs to be done some checking if the rate limit is set.

Embed field "Invalid value"

I've tried to put an URL for item.create with no http, such as "www.website.tld" into a embed field. The API warned me with that message: "Invalid value "www.website-example.ca" (string): must be integer".

I've put that same URL using Podio interface as a normal user can do, the result was valid as expected.

Is there something that I don't understand correctly?

Podio API appears to be returning the incorrect type for user emails in grants

Using the latest version of the Podio-PHP client for the API, calling PodioGrant::getfor( 'item', $itemid ) causes the following error notice:

Notice: Array to string conversion in /var/www/api/Podio/lib/PodioObject.php on line 162

When examining the data returned by the call (see snippet below), we notice that user mails has has been cast from array to string, causing a string of "Array" to be returned.

[user] => PodioUser Object
(
[_attributes:PodioObject:private] => Array
(
[userid] => 1234567
[profile_id] => 1234567
[name] => Joe Blogs
[link] => https://podio.com/users/1234567
[mail] => Array
[type] => user
)

This can be fixed temporarily by changing PodioObject.php[162] from

$this->attributes[$name] = $value ? (string)$value : null;

to

$this->attributes[$name] = $value ? ( is_array( $value ) ? $value : (string) $value ) : null;

Clearly, this isn't an ideal solution, and I suspect may need to be addressed elsewhere instead.

Timezone API not matching output (PHP)

Cannot get the correct output of time regarding Europe/Berlin summer- and wintertime.
We tried also date_default_timezone_set(), but did not get any correct output as been set in Podio.
Summertime comes out -2 hours. Wintertime adds one hour and comes out -1 hour.
For now we use this workaround:

function showTime....return $field->values[0]['start_time'];....

...$_time =
date('I',strtotime(showTime($item, $time_id))) == 1 ?
date('H:i', strtotime(showTime($item, $time_id).' +2 hours')) :
date('H:i', strtotime(showTime($item, $time_id).' -1 hours'));

Server side flow : Redirect loop

Hello !!

I have a probleme with the server side authentification. Yesterday, it was working great. But today, when my app connect to Podio with server side flow, i have an error message from my browser about Redirect Loop. I don't know why this problem began.

To use the app authentification, i use this link to connect to podio : https://podio.com/oauth/authorize?client_id=MY_APP_ID&redirect_uri=MY_URL

If i am not connected yet, i can login with the login page of podio.

But after connection, i am redirecting to my app URL and the error message appear. The problem occure with Firefox and Google Chrome (and i think IE too). I have to clear cache to display my app again.

Please, fix this issue shortly because i cannot work in my app. If it s not a bug and if it is because a bad config, tell me. I try everything.
And sorry for my english.

Redirect Loop Google Chrome

Redirect Loop Mozilla Firefox

MyApp Login Form

Login Page Podio

[improvement] Supporting images

In the Podio API client you can fetch the image url. But you cannot fetch the actual image itself (since you need authentication for that).

However, since the Podio::request method is authorized you could easily built it in there. For now I have changed it locally so it accepts a full url.

So I changed Podio.php line 195

if(strstr($url, 'http'))
{
    curl_setopt(self::$ch, CURLOPT_URL, $url);  
}
else
{
    curl_setopt(self::$ch, CURLOPT_URL, empty($options['file_download']) ? self::$url.$url : $url); 
}

and now I can pass in the full url for an image and load that image. This is just a quick fix, if this get's implemented it should be done with more care. Since now you can insert any url and thus sent your authentication credentials to another domain.

Error with PodioCalendarEvent::get_summary

Code:
$attr = array('limit' => 5, 'priority' => 1);
$events = PodioCalendarEvent::get_summary($attr);

Result:
Call to a member function json_body() on a non-object

Location:
podio-php/lib/PodioObject.php on line 145

Reading data from an object

/* Accesing my Leads app works well so far */
Podio::setup($client_id, $client_secret);
Podio::authenticate_with_app($app_id, $app_token);
$email = '[email protected]';
$student = PodioSearchResult::app( $app_id, array('query' => $email) );
$id = $student->id;

Podio::authenticate_with_app($second_app_id, $second_app_token);

/* This is the only way I can pull the data I need */
$info = PodioItem::filter($second_app_id, array(
'filters' => array(71281337 => $item_id)
));

/* This returns a private object from which I can't even read it's id. It shows all of the object contents using print_r but I can't read the object values. */
$student_id = $info->id;

/* If i do a print_r($info) I can see the object in all it's majesty but I am not able to read it's content */

Unable to set/update a date field

When I'm trying to set/update an existing date field, I get that error:

PHP Notice: Undefined index: end_date_utc in path/podio-php/models/PodioItemField.php on line 400

I've tried those lines from the doc:

  1. $item->fields['date-sent']->start = "2012-12-24";
  2. $item->fields['date-sent']->start_date = DateTime::createFromFormat('Y-m-d', '2012-12-24', new DateTimeZone("UTC"));
  3. $item->fields['date-sent']->end= "2012-12-24";
  4. $item->fields['date-sent']->end_date = DateTime::createFromFormat('Y-m-d', '2012-12-24', new DateTimeZone("UTC"));

Furthermore, there's no data set/updated despite the warning.

Thanks for any fix!

Undefined index: end_date_utc

When I try to get the start_date from a date field i get the following error:

Undefined index: end_date_utc

@

../podio/podio-php/models/PodioItemField.php:387

I checked var_dumped the PodioDateItemField and noticed that there are only the following array keys:

["values"]=>
array(1) {
[0]=>
array(6) {
["start"]=>
string(19) "2014-05-16 14:32:00"
["start_date_utc"]=>
string(10) "2014-05-16"
["start_time_utc"]=>
string(8) "12:32:00"
["start_time"]=>
string(8) "14:32:00"
["start_utc"]=>
string(19) "2014-05-16 12:32:00"
["start_date"]=>
string(10) "2014-05-16"
}
}

That explains the undefined index error. But what can we do about it?

Kind Regards,
Ramiro Hammen

Error when calling ->save() on items with calculation fields

When I try to save items that have calculations using the $item->save() method, I get an Uncaught PodioBadRequestError: "Values cannot be set directly for calculated fields" returned.

I'm not trying to edit a calculation field, the only field I've modified has nothing to do with the calculation. It's causing me some issues as I need to remove a field, meaning I can't call ->save() directly on the field because it's been unset().

Currently using PodioItem::update() with a null value as a workaround.

Item returned using PodioItem::filter doesn't contain all values

When selecting all items for an application using PodioItem::filter function, the resulting array of PodioItems doesn't contain all the information on the item. That is, the the items in the the array have not tags or files fields.

If you get a specific item using PodioItem::get function, the item returned does contain the tags and file values.

Clone item to another Workspace

I would be interested in duplicating an item to other Workspace(s) when a user creates a new item. The Apps within each Workspace have identical schema.

Get a field value?

Nice documentation here: http://podio.github.io/podio-php/items/

However, it doesn't say anything about how to simply retrieve a fields value. I have tried with the following:

$items = PodioItem::filter($this->options['app_id']);

foreach($items as $item) {
    echo $item->fields['titel'] . '<br />'; // returns an array
}

exclude_self = false in PodioContact

If I do:

PodioContact::get_for_space(SPACE_ID, array{
    'exclude_self' => false,
});

I get a "error_description":"Invalid value "" (string): must be {'1', 'on', 'true', 'y', 'yes', True, '0', 'false', 'n', 'no', 'off', False}","error":"invalid_value"}

This works:

PodioContact::get_for_space(SPACE_ID, array{
    'exclude_self' => "false",
});

Podio Form missing?

Am I see it correctly that PodioForm API is missing from this package? Is there a plan to add, or you would like to receive it from the community (maybe from me)?

Invalid headers issue on GAE (using cURL emulator)

Hi!
I'm developping a Google App and php is the must-use language. As CURL is not allowed on GAE, I used Matthijn's CURLEmulator (thank you for the code). It's working fine locally with the app engine SDK and should also work when deployed, but it doesn't.
It throws me this error and breaks all the app.

Warning: file_get_contents(https://api.podio.com:443/oauth/token): failed to open stream: Invalid headers. Must be a string. in /base/data/home/apps/swt-project1/9.374068374348827964/static/curlEmulator.php on line 171 Notice: Undefined variable: http_response_header in /base/data/home/apps/swt-project1/9.374068374348827964/static/curlEmulator.php on line 177 Warning: implode(): Invalid arguments passed in /base/data/home/apps/s~wt-project1/9.374068374348827964/static/curlEmulator.php on line 80

Thinking that the app is somehow based on this Podio connection, I'm really stuck.
Anyone got an idea?

Thanks a lot!

Create / save field to an Item

I loop through a collection of items, and for every item, I wish to either update the current field, or add it if it does not exist, however, I have not found an easy way to do this through the documentation.

Current approach:

$items = PodioItem::filter($this->options['app_id']);

foreach($items as $item) {
    $field = ($item->fields["my-field"]) ? $item->fields["my-field"] : new PodioItemField("my-field");
    $field->values = rand(1,9);
    $field->save();
}

Generates following error:

Fatal error: Uncaught PodioMissingRelationshipError: "Field is missing relationship to item

Is there another easier way? If not, how do I assign the relationship?

getting an error when running using PHPunit

so i got this library of mine
https://github.com/paperdarwin/podio

when i try to fetch an item in here
https://github.com/paperdarwin/podio/blob/master/src/Paperstreetmedia/Podio/Repositories/API/REST/RESTProjectRepository.php#L20

Note: I initialized my keys and etc in the constructor

but when you run this app in command line using PHPunit

vendor/bin/phpunit --stderr

im getting

Configuration read from /home/darwin/podio/phpunit.xml

...E

Time: 1.34 seconds, Memory: 3.00Mb

There was 1 error:

  1. RESTProjectRepositoryTest::testGetProject
    PodioForbiddenError:

/home/darwin/podio/vendor/podio/podio-php/lib/Podio.php:260
/home/darwin/podio/vendor/podio/podio-php/lib/Podio.php:290
/home/darwin/podio/vendor/podio/podio-php/models/PodioItem.php:76
/home/darwin/podio/src/Paperstreetmedia/Podio/Repositories/API/REST/RESTProjectRepository.php:20
/home/darwin/podio/tests/Unit/Paperstreetmedia/Podio/Repositories/API/REST/RESTProjectRepositoryTest.php:12

FAILURES!
Tests: 4, Assertions: 3, Errors: 1.

im sure my app keys are correct

Podio error can throw exception in __toString()

In the PodioError.php file an exception can be thrown in the toString when there is no body. This can be fixed by adding an empty check.

$body = (empty($this->request['body'])) ? '' : json_encode($this->request['body']);
$str .= "\nRequest Body: ".$body;

Please add function to pull items by IDs

Can we please have a simple function to ftecha list of items given a list of ids,?

//Something like

public static function getItemsByIds() {
$ids = array('74567', '355456', '437950');
return self::member(Podio::post("/itemsByIds"));
}

My integration has simply stalled due to this. Com'on podio you can do this.

Using autoloader/composer not possible

I'd like to use the Podio API using composer/autoloader. That isn't possible at the moment.

One of the advantages is that you can use a PSR-0 compliant autoloader, so you can improve the performance of your application. Any well-design framework uses a PSR-0 compliant autoloader:

Using a composer makes it easier to use Podio in your application. See https://packagist.org/ and http://getcomposer.org/ for more information.

Start session only if not started yet.

Little Bug: Start session only if not started yet.

podio-php/lib/PodioSession.php, Line 9

Old: session_start();

New: if(!session_id()) session_start();

The usage of the @filename API for file uploading is deprecated - File upload

Line 179: Lib/Podio.php throws an error when calling it as suggested in documentation:
http://podio.github.io/podio-php/api-requests/

curl_setopt(): The usage of the @filename API for file uploading is deprecated. Please use the CURLFile class instead

If you either remove the @ from the filename, it seems to work successfully... or if you create a CURLFile object like so:

      // Create a CURLFile object
      $cfile = curl_file_create( $attributes[ "source" ] );

      // Assign POST data
      $data[ $attributes[ "filename" ] ] = $cfile;
      curl_setopt(self::$ch, CURLOPT_POST,1);
      curl_setopt(self::$ch, CURLOPT_POSTFIELDS, $data); 

it also works.

There is however a PodioError that returns no message after calling this with the above changes... Any ideas?

http://stackoverflow.com/questions/27273695/error-when-using-file-upload-method-podio-api

Server-side flow authentication example contains bugs

in the first if the condition in the example is !isset($_GET['code']) && Podio::is_authenticated(), this never triggers the log in link, Podio::is_authenticated() results in FALSE when not logged in... it should be: !isset($_GET['code']) && !Podio::is_authenticated() (note the exclamation mark).

Also, the finalization Podio::authenticate_with_authorization_code call needs a comme. It is now: Podio::authenticate_with_authorization_code($_GET['code'] REDIRECT_URI);, it should be: Podio::authenticate_with_authorization_code($_GET['code'], REDIRECT_URI);

Just thought I post it here, took me a while to figure out why copy/pasted code from the docs was throwing errors (the missing comma) and then resulting in a blank screen not doing anything (no condition is met when not logged in).

Date-range handling

in the api_friendly_values() function, if a start date exists but does not have an end date, an error is thrown: Undefined index (end) etc. Here's my fix, starting at line 158:

case 'date':
if (!empty($this->values[0]['start']) AND !empty($this->values[0]['end'])) {
return array('start' => $this->values[0]['start'], 'end' => $this->values[0]['end']);
}
else {
return array('start' => $this->values[0]['start']);
}
break;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.