문제

I'm trying to use Facebook Graph API to upload a photo to a Facebook Fan page, I was able to upload the photo but it is uploaded as a small thumbnail with my hostname written beside it twice (i.e. www.myhost.comwww.myhost.com)

I need to upload the photo with its original size without anything written beside it

I'm using:

$params = array(
   "access_token" => $access_token,
   "picture" => "http://www.myhost.com/fb/Azkar-001.png",
);
$ret = $fb->api('/myID/feed', 'POST', $params);

Appreciate your feedback as I'm new with the graph API

도움이 되었습니까?

해결책 2

Thanks to Adam, HYG the full code:

<?php
require_once("facebook.php");

$access_token = "Add_Your_Access_Token_here";

$facebook = new Facebook(array(
   'appId'  => 'Add_Your_App_ID_Here',
   'secret' => 'Add_Your_App_Secret_Here',
   'fileUpload' => true, // I put this as False in my original program and this was the reason for my early issues
   'cookie' => true // enable optional cookie support
));

$facebook->setFileUploadSupport(true);

$file = "@".realpath("001.png"); //Put the file path here

$args = array(
   "message" => "Photo Caption'"
   "access_token" => $access_token,
   "image" => $file
);

$data = $facebook->api('/me/photos', 'post', $args); //This is the line that made everything working fine, thanks to Adam

if ($data) print_r("success");

?>

다른 팁

A common mistake is using me/feed, me/feed targets and publish status updates & link posts to the user's stream

To upload a photo to the user stream/timeline use me/photos

$ret = $fb->api('/me/photos', 'POST', $params);

wait, you still have another problem, which's using the param picture, why? because you're uploading from a URL, replace picture with url

$params = array(
   "access_token" => $access_token,
   "url" => "http://www.myhost.com/fb/Azkar-001.png",
);
$ret = $fb->api('/me/photos', 'POST', $params);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top