Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improvement] Supporting images #40

Closed
Matthijn opened this issue Jan 6, 2014 · 3 comments

Comments

Projects
None yet
2 participants
@Matthijn
Copy link

commented Jan 6, 2014

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.

@haugstrup

This comment has been minimized.

Copy link
Contributor

commented Jan 6, 2014

You can use the get_raw method to download files:

// Get the file object. Only necessary if you don't already have it!
$file = PodioFile->get($file_id);

// Download the file. This might take a while...
$file_content = $file->get_raw();

// Store the file on local disk
file_put_contents($path_to_file, $file_content);

This is the preferred way to downloading files from Podio

@haugstrup haugstrup closed this Jan 6, 2014

@Matthijn

This comment has been minimized.

Copy link
Author

commented Jan 7, 2014

Isn't that the "attachment files" for an item? You can have an item field in your app. If that works with images too you can close this. Because that is a better way to go for it.

edit: I see it is already closed :)

@haugstrup

This comment has been minimized.

Copy link
Contributor

commented Jan 7, 2014

It works for all file objects from Podio. When you get an item with an image field you can use e.g. $file_content = $item->field('image-field-ext-id')->files()[0]->get_raw() to get the contents of the first file (->files() returns an array of PodioFile objects)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.