我见过很多 Facebook 应用程序会自动上传照片并发布。
C# .NET
JsonObject jasonObj = CreateAlbum(accessToken);
UploadPhoto(jo["id"].toString(""), accessToken, filename);
public JsonObject CreateAlbum(string accessToken)
{
FacebookClient facebookClient = new FacebookClient(accessToken);
Dictionary<string, object> albumParameters = new Dictionary<string, object>();
albumParameters.Add("message", "My Album message");
albumParameters.Add("name", "Album Name");
JsonObject resul = facebookClient.Post("/me/albums", albumParameters) as JsonObject;
return resul;
}
public void UploadPhoto(string AlbumId, string accessToken, string FullImagePath)
{
byte[] photo = File.ReadAllBytes(FullImagePath);
FacebookApp app = new FacebookApp();
dynamic parameters = new ExpandoObject();
parameters.access_token = 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 = "top.jpg",
ContentType = "image/jpeg",
};
mediaObject.SetValue(photo);
parameters.source = mediaObject;
dynamic result = app.Api(String.Format("/{0}/photos", AlbumId), parameters, HttpMethod.Post);
}
但那张照片并没有在时间轴上发布。
您想将这些照片添加到您的相册吗?下面的照片是从另一个应用程序上传的,您需要批准它们。
这是 Facebook 的政策吗?还是我的错?