C# facebook graph / How to upload to album id

后端 未结 1 965
孤独总比滥情好
孤独总比滥情好 2020-12-16 08:26
Dictionary newPhotoParam = new Dictionary();

newPhotoParam.Add(\"access_token\", _app.AccessToken);
newPhotoParam.Add(\"         


        
相关标签:
1条回答
  • 2020-12-16 09:28

    This is code take from one of my unit tests which is included in the source of the SDK. This is how you would upload a photo:

            string photoPath = @"..\..\..\Facebook.Tests\bin\Release\monkey.jpg";
            string albumId = ConfigurationManager.AppSettings["AlbumId"];
            byte[] photo = File.ReadAllBytes(photoPath);
    
            FacebookApp app = new FacebookApp();
            dynamic parameters = new ExpandoObject();
            parameters.access_token = ConfigurationManager.AppSettings["AccessToken"];
            parameters.message = "This is a test photo of a monkey that has been uploaded " +
                                 "by the Facebook C# SDK (http://facebooksdk.codeplex.com)" +
                                 "using the Graph API";
            var mediaObject = new FacebookMediaObject
            {
                FileName = "monkey.jpg",
                ContentType = "image/jpeg",
            };
            mediaObject.SetValue(photo);
            parameters.source = mediaObject;
    
            dynamic result = app.Api(String.Format("/{0}/photos", albumId), parameters, HttpMethod.Post);
    
    0 讨论(0)
提交回复
热议问题