News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Phil Sturgeon:
CurlFile and the Facebook SDK in PHP 5.5
August 30, 2013 @ 11:19:04

Phil Sturgeon has a new post to his site today looking at a new feature that's included with PHP 5.5, Curlfile, and how he uses it with calls to the Facebook API (and a fix to make it cooperate).

One of the features implemented in PHP 5.5 was CurlFile, a nice addition to the Curl extension to allow you to specify specific arguments as a file for upload. In previous versions (pre-PHP 5.5) the syntax looked like this: [@/foo/bar.jpg]. A little digging around lead me to try this syntax: [new CURLFile('/foo/bar.jpg','image/jpeg')]. Sadly while Curl was happy with this, the Facebook PHP SDK (v3.2.2) was not. It turns out the SDK will turn ANY value you send it in that params array into a string.

To get around the issue, he worked up his own fix to the Facebook PHP SDK and submitted a patch to get it introduced into the tool. He also includes a reminder to filter incoming user data for things containing the "@" too to prevent unwanted file transfers.

0 comments voice your opinion now!
curlfile curl file upload facebook sdk patch json

Link: http://philsturgeon.co.uk/blog/2013/08/curlfile-and-the-facebook-sdk-in-php-55

blog comments powered by Disqus

Similar Posts

Elizabeth Smith's Blog: Xdebug, Thread Safety, and PHP 5.3

David Coallier's Blog: Namespaces has PHP 5.3 (Or the other way around)

DevShed: PHP Closures as View Helpers: Lazy-Loading File Data

DevShed: Uploading Files and Navigating Directories in PHP

Elizabeth Smith's Blog: Compiling PHP5.2 on Windows with .Net toolchain - is it even possible?


Community Events





Don't see your event here?
Let us know!


configure install laravel podcast unittest interview refactor testing developer community framework introduction list code threedevsandamaybe series symfony2 language release opinion

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework