Publishing to Facebook with Graph API
What if you want to post something to a user's news feed, publish a photo, or post a status update for a user?
It turns out that Facebook makes these tasks really easy. In fact, it's so easy that if you understand the things I discuss in the first half of the chapter, you can probably do it with little or no additional explanation from me.
POSTing data
Publishing to Facebook is as simple as making a POST request on your Graph API call instead of a GET request. Where it may get difficult for you is, because it is a POST request, you can't necessarily type it into a Web browser URL bar to make it work. That's okay, though, because you can still play with it using a tool like Curl to make your request from a command line.
Curl is a command-line tool available for most operating systems that allows you to make HTTP requests. By passing the right parameters, you can make GET requests and POST requests, and it returns the data similar to what I show in simple GET requests from the browser so far — only on the command line. Curl can be a great tool for making test POST requests without writing any code. To initiate a POST request in Curl, just specify a parameter or two using the -F parameter.
Curl comes by default with most operating systems, but it does not come with Windows. To install Curl for Windows, go to http://curl.haxx.se/dlwiz/?type=bin ...
Get Facebook® Application Development For Dummies® now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.