可能重复:
How to retrieve post ID for a post i’ve just made via the Facebook API
我正在尝试使用Facebook C#SDK,并希望找到用于在我的应用中将照片发布到墙上时使用的变量。我知道我需要找到照片的ID,但我运气不好。我尝试使用_lastMessageID,但它没有用。这是我正在使用的代码中没有在postingPictureUrl中的必要变量:
private async void PostToWall_Click(object sender, RoutedEventArgs e)
{
try
{
dynamic parameters = new ExpandoObject();
parameters.message = txtMessage.Text;
StorageFile imageFile = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Images/photo.png"));
IRandomAccessStream fileStream = await imageFile.OpenAsync(FileAccessMode.Read);
var reader = new Windows.Storage.Streams.DataReader(fileStream.GetInputStreamAt(0));
await reader.LoadAsync((uint)fileStream.Size);
byte[] pixels = new byte[fileStream.Size];
reader.ReadBytes(pixels);
parameters.picture = new FacebookMediaObject
{
ContentType = "image/png",
FileName = "photo.png",
}.SetValue(pixels);
dynamic result = await _fb.PostTaskAsync("me/photos", parameters);
_lastMessageId = result.id;
txtMessage.Text = string.Empty;
btnDeleteLastMessage.IsEnabled = true;
string postedPictureUrl = string.Format("https://graph.facebook.com/{0}/photos?&access_token={2}", _userId, _fb.AccessToken"); //this is where I need to retrieve the id of the photo...
myPostedPainting.Source = new BitmapImage(new Uri(postedPictureUrl));
}
catch (FacebookApiException ex)
{
// handle error message
}
}