2 followers Follow

Download Podio item image to server (PHP)


I've set up some webhooks that sends Podio-data to a MYSQL-database on my server, works like a charm. Now I only need to fetch the attached image and store the file in a directory on the same server, here's where I'm stuck.

First I was trying to use the direct links (like but now understand they are not public, so in some way "get_raw" is the way to go but I don't get any of the example code-snippets to work.

I also understood that my hosting provider (Loopia wiki) does not allow allow_url_fopen which leaves out file_get_contents-solution.
Loopia WIKI (Swedish):Öppna_och_inkludera_filer_från_fjärrplats

I read, tried and obviously failed to use the following hints:

A Screenshot: (echo $file shows a lot of ??!=#€€, is that my image data?)

* Do I have to authenticate in some special way to use get_raw?
* Is it possible to show the image response directly in the browser (for debugging purposes)?
* I don't only want the full scale image, but also the medium/badge-versions. How do I do that, now that I can't use

Can anyone point me in the right direction here? :)


Stefan Falkboman

Please sign in to leave a comment.



The gibberish you output is the image data, but your destination path /folder/testbild.jpg doesn't look right. It'll save the image on an absolute path from the root of your file system. That's most likely not what you want. You'll want to remove the starting / to save the file relative to your PHP file.

Andreas Haugstrup Pedersen 1 vote

Incredible, that was it! So much work for one / ...

I now have:
$item_id = "156896776";
$item = PodioItem::get($item_id);
$file = $item->field(24275404)->files()[0]->get_raw();
file_put_contents("folder/testbild.jpg", $file);

And how about my second question, can I fetch the other file sizes using the same "get_raw" method?

Stefan Falkboman 0 votes

You can see what the get_raw() method does here:

If you do the same with a thumbnail URL you can get the resized URLs as well. It's probably better if you download only the original from Podio and generate your own thumbnails from the original (using GDlib or imagemagick).

You can serve an image directly from PHP if you send the right headers:

Andreas Haugstrup Pedersen 0 votes

Ok thanks, I managed to create the thumbnails using Imagemagick instead. But I still need to access the "extra_large"-version from Podio instead of starting from potentially huge full size uploads (that are very slow).

But I can't figure out how to do something like GET_RAW on the extra_large version instead.
I know I want to fetch this URL for instance:

  1. GET_RAW gets the "link" attribute.
  2. Theres is no "extra_large_link" attribute.
  3. I tried to replace the "$this->link" with "link + /extra_large".

public function get_raw() {
return Podio::get($this->link, array(), array('file_download' => true))->body;

Thanks for you help so far!

Stefan Falkboman 0 votes

I tried doing this without modifying core files but didn't manage (due to poor coding skills).

So I simply duplicated the get_raw function in PodioFile.php and added . "/extra_large" according to you suggestion.

public function get_raw_large() {
return Podio::get($this->link . "/extra_large", array(), array('file_download' => true))->body;

That worked, and I suppose it could be done with /medium too :)


Thanks Andreas for all the support!


Stefan Falkboman 0 votes

Ok, I'm on this again and still couldn't figure out how to use the new functionality. I'm most likely just a PHP-looser.

I'm supposed to send the size parameter somehow in the get_raw():

$file = PodioFile::get($image_id);
file_put_contents("folder/".$my_url, $file->get_raw());

I tried:
$size='medium'; get_raw());

But I ended up doing it manually :-)

$file = Podio::get($podio_image->values[0]->link . '/medium', array(), array('file_download' => true))->body;

file_put_contents("folder/".$my_url, $file);


Stefan Falkboman 0 votes