0

I need help understanding whether or not this is the intended behavior or if it's something that is not supported. What I want to do is upload a photo to a Facebook page post that is targeted to a specific country.

The steps I take are:

1) Upload the photo to a public album (e.g. Timeline Photos) 2) Retrieve the uploaded photo id from the album 3) Create an attachment to the post with the photo id from step #2

The problem is that I'm now uploading a photo to a public album that is not targeted to a specific country. What I would like to do is to have BOTH the photo(s) and page contents be restricted by targeting. I see a picture parameter in the api, but I believe this is just for setting the page's profile picture.

Any ideas on how this may be accomplished or whether or not this is even possible? Any code examples would also be welcomed.

1 Answers1

0

After playing around with this more I found that I had to set the 'source' parameter to point to a file in my local file system (pointing to a remote file did not work). Not sure if the latter may be accomplished. Also, you have to make a call to setFileUploadSupport with true.

Pseudo code via PHP:

//Create a temporary file somewhere
$contents = ...
$tmpfname = tempnam(sys_get_temp_dir(), $prefix);
$handle = fopen($tmpfname, "w");
fwrite($handle, $contents);
fclose($handle);

//Add to params
$params['source'] = '@' . $tmpfname

$fb = FB_sdk::instance(true);
$fb->setFileUploadSupport(true);
$fb->api('[url to page]/photos', 'POST', $params);