我可以使用Facebook Graph API将照片上传到属于粉丝(公司)页面墙的墙上吗? [英] Can I upload photos to a wall belonging to a fan (company) page wall using the Facebook Graph API?

查看:67
本文介绍了我可以使用Facebook Graph API将照片上传到属于粉丝(公司)页面墙的墙上吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道是否有可能这样做,以便授权用户可以使用图形API将照片上传到公司的粉丝页面(墙上). 此外,一旦授权用户,是否有可能通过api变成公司页面(成为粉丝).

I need to know if it's possible to make it so authorized users can upload photos to a fan page of a company (to the wall) using the graph API. Also, is it possible to become like (become a fan) of a company page through the api once the user is authorized.

推荐答案

可以.您需要使用Graph API资源管理器(https://developers.facebook.com/tools/explorer)并调用

Yes you can. You need to obtain your admin access token by using the Graph API explorer (https://developers.facebook.com/tools/explorer) and with a call to

https://graph.facebook.com/ {adminfacebookid}/帐户

https://graph.facebook.com/{adminfacebookid}/accounts

这将列出您的管理员有权访问的所有页面和应用程序.查找有问题的粉丝页面,然后复制accessToken.

this will list all pages and apps your admin has access to. Look for the fan page in question and copy the accessToken.

接下来,通过单击页面的ID,然后在请求中添加/albums,获得相册名称

Next get the albumid by clicking on the id of the page, then adding /albums to the request

为此,您可以使用facebook Web客户端将图像数据发布到url

armed with this you can then post the image data to the url, using the facebook web client

像这样

protected void PublishToPublicGallery(string accessToken, string filename, long albumId, string imagename)
        {

            var facebookClient = new FacebookClient(accessToken);
            var mediaObject = new FacebookMediaObject
            {
                FileName = filename,
                ContentType = "image/jpeg"
            };
            var fileBytes = System.IO.File.ReadAllBytes(filename);
            mediaObject.SetValue(fileBytes);

            IDictionary<string, object> upload = new Dictionary<string, object>();
            upload.Add("name", imagename);
            upload.Add("source", mediaObject);
            var result = facebookClient.Post("/" + albumId + "/photos", upload) as JsonObject;    
        }

这篇关于我可以使用Facebook Graph API将照片上传到属于粉丝(公司)页面墙的墙上吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆