Picnik Forums
   Home   Help Search Login Register Picnik.com  
 
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Pages: [1]
Print
Author Topic: Solution to problem with not being able to upload file to Picnik via cURL/PHP  (Read 995 times)
Camelback
posted: December 08, 2009, 07:53:28 AM

We were trying to integrate Picnik with our CMS called liveSite (http://www.camelback.net/?t=forums.picnik.com).  We were having a difficult time trying to upload a file to Picnik via cURL and PHP (it would just timeout), until we finally discovered that the line below is required.

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));

We are using the code below successfully.

Code:
$file = '/path/to/example.gif';

$post_data = array();
$post_data['_import'] = 'image_file';
$post_data['image_file'] = "@$file";
$post_data['_returntype'] = 'text';
$post_data['_apikey'] = '*****';

// initialize cURL
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'http://www.picnik.com/service/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 999);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_FORBID_REUSE, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));

// get cURL response
$response_data = curl_exec($ch);

We discovered this at the link below.

http://svn.concrete5-japan.org/svn/c5japan/5.3.3/trunk/concrete/tools/files/edit/image.php

Hopefully this information saves someone a lot of time.
Pages: [1]
Print
 
Jump to:  

Powered by SMF 1.1 RC2 | SMF © 2001-2005, Lewis Media | © 2006-7 Picnik, Inc.