0

I'm trying to do something with Podio API, I'm a beginner. So my code is:

PodioItem::create($app_id, array('fields' => array(
"title" => ($name . " " . $surname),
"adres-e-mail-2" => $email,
), 
array("file_ids" => $file->id) ));

Item is created without problems, but without a file uploaded. Error log throws only deprecation:

PHP Deprecated: curl_setopt(): The usage of the @filename API for file uploading is deprecated. Please use the CURLFile class instead in /home/avat/public_html/avat/aiesec/test/podio/lib/Podio.php on line 179

File upload script is working, I can save it to my folder. I have Podio file ID working. I don't really know where to look for errors now.

Avat
  • 3
  • 1
  • It is pretty obvious, the code that the Podio contains uses deprecated features of php. Fix or burn the script. – Ronni Skansing Jun 30 '14 at 10:43
  • OK, I reverted PHP version to 5.3 which accepts Podio scripts without errors. Currently script works and throws no errors at all, but file stil does not upload. Any ideas? – Avat Jun 30 '14 at 12:24
  • Yea look for warnings or errors in logs. Make sure to have error reporting and such activated. But butter would be not to downgrade, upgrade to the newst version and some nice maintained code that works tommorow also. – Ronni Skansing Jun 30 '14 at 13:07

1 Answers1

3

It's almost always easier to work with objects rather than the static methods. As for uploading a file I've broken the example below out in sections so it's easier to see what's going on:

// Upload file
$file = PodioFile::upload("/Users/andreas/Desktop/irwin.jpg", "irwin.jpg");

// Create a new item object
$item = new PodioItem(array(
  'app' => new PodioApp(8018420),
  'fields' => new PodioItemFieldCollection()
));

// Set a value for the field with the external id 'title'
$item->fields['title'] = new PodioTextItemField();
$item->fields['title']->values = $name . " " . $surname;

// Create a new collection for files and add the $file to this collection
$item->files = new PodioCollection(array($file));

// Save the item to Podio
$item->save();

See more at: