English 中文(简体)
Can I upload photos to a wall belonging to a fan (company) page wall using the Facebook Graph 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.

问题回答

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}/accounts

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

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

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

like this

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 Connect login dialog not working

I am using Facebook Connect for iPhone and following the official instructions. I use the following code to display the login dialog: FBLoginDialog* dialog = [[[FBLoginDialog alloc] initWithSession:...

Facebook App Profile Tab is Empty ... No Content Displayed?

I can view my application via the http://apps.facebook.com/myapplication/ link and the content shows up correctly. I also added the application as a tab to a facebook page. However, when viewing the ...

Facebook Platform error: "Object cannot be liked"

I m working on a Facebook Application that generates wall posts. In testing these posts, I ve discovered that the Facebook Platform action of "liking" a post is failing. The specific error message ...

how to call showPermissionsDialog() in php (facebook api)?

I was reading over the documentation yet I could not figure out how to call Facebook.showPermissionsDialog() in php include_once ./facebook-platform/php/facebook.php ; $facebook = new Facebook(my ...

Facebook connect

If I plug in the facebook connect into my website, How can I prevent double signups? Lets say I have a user that s already signed up to my site but he clicked the connect with facebook, is there a ...

热门标签