31 May

Facebook Graph API using PHP SDK – CurlException: 26

I was playing around with the Facebook Graph API using the PHP SDK to upload photos and was having some issues.

I kept getting “CurlException: 26: failed creating formpost data” and was certain my code was solid. Turns out, this indicated a permissions issue with the photo I was trying to upload to Facebook. I checked, and certainly enough, my photo permissions were “No Access” to the picture for users other than myself on Mac OS X. I then set the permissions for “Everyone” to “Read Only” and all is working fine and dandy now.

Here is my working code for uploading a photo from the same directory as the PHP page communicating with Facebook:

	$facebook->setFileUploadSupport(true);
	$args = array(
		'message' => 'I am awesome.',
		'image' => '@' . realpath('awesome.jpeg')
	);
	try {
		$data = $facebook->api('/me/photos', 'post', $args);
	} catch(FacebookApiException $e) {
		echo "ERROR: " . $e;
	}

May 31, 2011 in: Technology - No Comments