简体   繁体   中英

PHP - Facebook API will not upload pictures

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?

您使用/me/feed定位用户供稿的简单错误,而是使用me/photos定位了用户的照片,因此最终的API调用看起来像

$fb->api('/me/photos', 'POST', $param);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM