php – 通过电子邮件发送照片到我的Facebook页面
发布时间:2020-12-13 22:33:24 所属栏目:PHP教程 来源:网络整理
导读:我们运行Facebook粉丝页面www.facebook.com/GowerLive,其中包含我们在高尔半岛上的3个网络摄像头的图像和更新;我想使用Facebook上的功能,它允许您在每天晚上8点使用CRON作业中的唯一电子邮件地址将照片直接通过电子邮件发送到您的粉丝页面. 我已经测试了电子
我们运行Facebook粉丝页面www.facebook.com/GowerLive,其中包含我们在高尔半岛上的3个网络摄像头的图像和更新;我想使用Facebook上的功能,它允许您在每天晚上8点使用CRON作业中的唯一电子邮件地址将照片直接通过电子邮件发送到您的粉丝页面.
我已经测试了电子邮件地址……工作正常,我可以提交图像,但我的PHP脚本不显示照片.它将主题发布到Facebook,但就是这样. 首先,这是将图像添加到我的粉丝页面的最佳方式吗? // array with filenames to be sent as attachment $files = array("public_html/langcam/09.jpg","public_html/langcam/13.jpg","public_html/langcam/16.jpg","public_html/caswellcam/09.jpg","public_html/caswellcam/13.jpg","public_html/caswellcam/16.jpg","public_html/llangcam/09.jpg","public_html/llangcam/13.jpg","public_html/llangcam/16.jpg"); // email fields: to,from,subject,and so on $to = "uniqueaddress@m.facebook.com"; $from = "email@mysite.com"; $subject = "On ".date("F j,Y")." the wavebuoy at 1pm was ". $waveheightb."ft @ ".$seconds."seconds with a ".$windcompass." wind at ".$windspeedb."mph"; $message = "I normally leave this blank"; $headers = "From: $from"; // boundary $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; // headers for attachment $headers .= "nMIME-Version: 1.0n" . "Content-Type: multipart/mixed;n" . " boundary="{$mime_boundary}""; // multipart boundary $message = "This is a multi-part message in MIME format.nn" . "--{$mime_boundary}n" . "Content-Type: text/plain; charset="iso-8859-1"n" . "Content-Transfer-Encoding: 7bitnn" . $message . "nn"; $message .= "--{$mime_boundary}n"; // preparing attachments for($x=0;$x<count($files);$x++){ $file = fopen($files[$x],"rb"); $data = fread($file,filesize($files[$x])); fclose($file); $data = chunk_split(base64_encode($data)); $message .= "Content-Type: {"application/octet-stream"};n" . " name="$files[$x]"n" . "Content-Disposition: attachment;n" . " filename="$files[$x]"n" . "Content-Transfer-Encoding: base64nn" . $data . "nn"; $message .= "--{$mime_boundary}n"; } // send $ok = @mail($to,$subject,$message,$headers); if ($ok) { echo "Mail sent to $to!"; } else { echo "Mail could not be sent!"; } 谢谢 背风处 解决方法
李,
您可能想要查看Facebook Graph API.我不确定它是否适用于粉丝页面,但是没有理由不这样做.忽略博客文章标题,然后向下滚动到文章的第二部分,了解如何创建相册并将照片上传到相册. https://developers.facebook.com/blog/post/498/ 用于照片的Facebook Graph API页面位于以下URL: http://developers.facebook.com/docs/reference/api/photo/ 或者在http://ifttt.com上创建一个ifttt脚本,因为它可能更容易. 乔恩 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |