I'm making a website that users can upload photos to facebook via PHP Facebook api.
if a user attach a photo it should go to their album directly. It's weird that it used to work but now it's not working.
here's the code
$facebook->setFileUploadSupport(true);
$userPhoto = $_FILES["pic"]["tmp_name"];
$fb_photoUpdate = $facebook->api('/$fb_id/photos/', 'post', array('source'=>'@'.realpath($userPhoto), 'message'=> 'photo uploaded successfully!'));
$fb_id is facebook user id. I save user's id in database when they first login on my website. Also, I save their access token.
I want to use &fb_id instead of /me. Is there any way to make this code work? Should I add access token there?
Please help me and Thanks in advance.
Plus, I've tried like this
$facebook->setFileUploadSupport(true); ?>
<script language="javascript">alert('1');</script>
<?php try { ?>
<script language="javascript"> alert('2');</script>
<?php $fb_photoUpdate = $facebook->api('/$fb_id/photos/', 'post', array('source'=>'@'.realpath($userPhoto), 'message'=> $_POST['posting'])); ?>
<script language="javascript"> alert('3');</script>
<?php }
But, All I got was alert 1, alert 2. There was no alert 3 and also i didn't get any errors from console.
try changing $userPhoto = $_FILES["pic"]["tmp_name"];
to $userPhoto = $_FILES["pic"];
If not, are there any error codes you can share with us?
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.