如何将这些数据发送到Facebook? Facebook api照片上传 [英] how do i send this data to facebook? facebook api photo upload
本文介绍了如何将这些数据发送到Facebook? Facebook api照片上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好的,facebook要我发送本地存储在服务器上的图像,但是我将图像存储在数据库的BLOB中...
Okay so facebook want me to send an image stored locally on the server but i have the images stored in a BLOB in the database...
try {
$file = 'http://blaze-craft.com/matt/get.php?id=' . $lastid;
$post_data = array(
"message" => "Uploaded using the Funnymemes app!",
"source" => $file
);
$data['photo'] = $facebook->api("/me/photos", 'post', $post_data);
}
catch (FacebookApiException $e) {
}
但是它没有上传...我从facebook api doc那里获得了这段代码,所以我不确定发生了什么事情
but its not uploading... I got this code from the facebook api doc's so im not sure whats going on?
有什么想法吗?
推荐答案
要使照片上传正常工作,您必须解决以下问题:
In order to photo upload to work you have to fix these:
- 图像文件应存储在文件系统中(即将BLOB保存回 磁盘)
- 在
$post_data
数组中的图像路径之前使用@
.
- Image files should be stored in filesystem (i.e. save BLOB back to the disk)
- Use
@
before image path in$post_data
array.
为此,我会做类似的事情:
For this purpose i would do something like:
try
{
$url = 'http://blaze-craft.com/matt/get.php?id=' . $lastid;
$saveas = '/images/image.jpg';
$res = @file_put_contents($saveas, file_get_contents($url));
if($res === false) throw new Exception('Cannot fetch image');
$post_data = array(
"message" => "Uploaded using the Funnymemes app!",
"source" => '@' . $saveas;
);
$data['photo'] = $facebook->api("/me/photos", 'post', $post_data);
}
catch (FacebookApiException $e) { }
catch (Exception $e) { }
这篇关于如何将这些数据发送到Facebook? Facebook api照片上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文