私は Facebook C# SDK を試していて、壁に投稿した写真をアプリに表示するために使用する変数を見つけたいと考えています。写真のIDを見つける必要があることはわかっていますが、うまくいきませんでした。使ってみ_lastMessageID
ましたがダメでした。これが私が使用しているコードであり、必要な変数はありませんpostedPictureUrl
:
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
}
}