Facebook图片api照片上传到粉丝专页

编程入门 行业动态 更新时间:2024-10-23 16:18:09
本文介绍了Facebook图片api照片上传到粉丝专页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经获得了照片上传功能以使用此代码,

I have gotten the photo upload function to work with this code,

<?php include_once 'facebook-php-sdk/src/facebook.php'; include_once 'config.php';//this file contains the secret key and app id etc... $facebook = new Facebook(array( 'appId' => FACEBOOK_APP_ID, 'secret' => FACEBOOK_SECRET_KEY, 'cookie' => true, 'domain' => 'your callback url goes here' )); $session = $facebook->getSession(); if (!$session) { $url = $facebook->getLoginUrl(array( 'canvas' => 1, 'fbconnect' => 0, 'req_perms'=>'user_photos,publish_stream,offline_access'//here I am requesting the required permissions, it should work with publish_stream alone, but I added the others just to be safe )); echo 'You are not logged in, please <a href="' . $facebook->getLoginUrl() . '">Login</a> to access this application'; } else{ try { $uid = $facebook->getUser(); $me = $facebook->api('/me'); $token = $session['access_token'];//here I get the token from the $session array $album_id = 'the id of the album you wish to upload to eg: 1122'; //upload your photo $file= 'test.jpg'; $args = array( 'message' => 'Photo from application', ); $args[basename($file)] = '@' . realpath($file); $ch = curl_init(); $url = 'graph.facebook/'.$album_id.'/photos?access_token='.$token; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $args); $data = curl_exec($ch); //returns the id of the photo you just uploaded print_r(json_decode($data,true)); } catch(FacebookApiException $e){ echo "Error:" . print_r($e, true); } } ?>

我希望这有帮助,一个朋友和我在墙上砸了一段时间,这个工作!

I hope this helps, a friend and I smashed our heads against a wall for quite some time to get this working!

无论如何,这是我的问题,如何将图片上传到粉丝专页?我努力工作,当我上传图像,我得到的是照片的ID,但没有照片在相册。

Anyways, here is my question, how can I upload a image to a fan page? I am struggling to get this working, when I upload the image all I get is the photo id but no photo in the album.

所以基本上,当用户点击上传按钮在我们的应用程序,我需要它将他们创建的图像上传到我们的粉丝页面的相册与他们的标签。

So basically, when the user clicks the upload button on our application, I need it to upload the image they created to our fan page's album with them tagged on it.

任何人都知道我可以如何实现这一点? / p>

Anyone know how I can accomplish this?

推荐答案

这似乎是Graph API的一个错误。请参阅这个 forum.developers.facebook/viewtopic.php? id = 59063 (不能发布链接)

This seems to be a bug with the Graph API. See this forum.developers.facebook/viewtopic.php?id=59063 (can't post links, yet)

更多推荐

Facebook图片api照片上传到粉丝专页

本文发布于:2023-06-05 19:41:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/526466.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:粉丝   照片   专页   图片   Facebook

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!