开发者

How to get the pictures of each entry in wall or news feed?

if I receive all entries with "/me/home" oder "XXXX/feed", each entry has an array "from" with ID and Name as fields. But no picture field.

How do I get the pictures of all entri开发者_运维百科es? I don't want to use a for-loop because I want to directly bind (WPF) the received data from "/me/home" to a ListBox.


Basically you have to get picture you have to pass ID and then get picture

Sorry for Bad Indentation

here goes the code

result = app.Get("/me/feed");
  string id = post.from.id;
  foreach (dynamic post in result.data)
  {
    if (id != tempId)
    {
      yourControl = getUrlImage("https://graph.facebook.com/" + id + "/picture");     
    }
  }

  private Image getUrlImage(string url) 
  {
    WebResponse result = null;
    Image rImage = null;
    try
    {
       WebRequest request = WebRequest.Create(url);
       result = request.GetResponse();
       Stream stream = result.GetResponseStream();
       BinaryReader br = new BinaryReader(stream);
       byte[] rBytes = br.ReadBytes(1000000);
       br.Close();
        result.Close();
       MemoryStream imageStream = new MemoryStream(rBytes, 0, rBytes.Length);
       imageStream.Write(rBytes, 0, rBytes.Length);
       rImage = Image.FromStream(imageStream, true);
       imageStream.Close();
       }
       catch (Exception c)
       {
          MessageBox.Show(c.Message);
       }
       finally
       {
          if (result != null) result.Close();
        }
        return rImage;
     }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜