-1

Teaching myself some Facebook feed posting via PHP and I'm trying to figure out how I would execute this curl HTTP POST via the the PHP curl command, any suggestions?

curl -X POST \
     -F 'message=Post%20with%20app%20access%20token' \
     -F 'access_token=YOUR_APP_ACCESS_TOKEN' \
     https://graph.facebook.com/4804827/feed

It's found here

VikingGoat
  • 387
  • 3
  • 8
  • 30

1 Answers1

1

This is how to do it:

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://graph.facebook.com/4804827/feed");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
    'message' => 'Post with app access token',
    'access_token' => 'YOUR_APP_ACCESS_TOKEN'
));

echo curl_exec($ch);
curl_close($ch);

I recommend looking at the documentation:

http://www.php.net/manual/en/function.curl-init.php

http://www.php.net/manual/en/function.curl-setopt.php

Luke
  • 13,678
  • 7
  • 45
  • 79
  • For some reason I wasn't putting two and two together for the documentation, this makes perfect sense now, thanks. – VikingGoat Mar 08 '13 at 19:12