Question

I am trying to write my own auto poster for a Facebook Page or 2, and it will not upload photos to the page.

Code:

<?php
require_once("./src/facebook.php");
require("functions.php");
$f = getFB();

$config = array(
    "appId" => $f['appID'],
    "secret" => $f['secret'],
    "fileUpload" => true,
    "allowSignedRequest" => false
);

$fb = new Facebook($config);
$uid = $fb -> getUser();
$param = array(
    "access_token" => $f['accessToken'],
    "message" => $_GET['msg'],
    "url" => "http://i.imgur.com/lHkOsiH.png",
);

try
{
    $ret = $fb -> api('/me/feed', 'POST', $param);
    echo "Successfully posted!";
    print_r($ret);
}
catch (Exception $e)
{
    die($e -> getMessage());
}
?>

It will upload just fine, but the result looks like this

How can I get the API to actually upload an image?

Was it helpful?

Solution

Simple error you used /me/feed which targets the user feed, to target the user's photos use me/photos instead, so the final API call would look like

$fb->api('/me/photos', 'POST', $param);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top