Получить фотографии с VK-поста - C#

Узнай цену своей работы

Формулировка задачи:

Всем привет, такая проблема. Надо получить фотографии с поста. то бишь загружается n постов, потом они парсятся, достаются из них текст и прикрепленные фалы (фотограии). Кто знает как получить и текст и фотографии. Вот код, до которого пока я додумался.
string request = CatcherData.useHttps
                    ? "https://"
                    : "http://" + "api.vk.com/method/wall.get.xml?domain=" + CatcherData.domain +
                      "&offset=0&filter=owner&count=" + CatcherData.postsCount +
                      (CatcherData.useAuth ? "access_token=" + CatcherData.accesToken : "");
                XDocument document = XDocument.Load(request);
                var response = from rsp in document.Descendants("post") select new
                {
                    
                };
Дальше просто не работает, просто нет идей, что выбрать из post. Кто может помочь чайник?) Заранее спасибо

Решение задачи: «Получить фотографии с VK-поста»

textual
Листинг программы
using System;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net.Http;
using Newtonsoft.Json.Linq;
using System.Drawing;
using System.IO;
 
namespace GetVkWallPicturesByJson
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
 
            textBoxOutput.ScrollBars = ScrollBars.Both;
            textBoxOutput.WordWrap = false;
        }
 
        private async void buttonGetPictures_Click(object sender, EventArgs e)
        {
            buttonGetPictures.Enabled = false;
            await GetPictures();
            buttonGetPictures.Enabled = true;
        }
 
        private async Task GetPictures()
        {
            using (var client = new HttpClient())
            {
                var resp = await client.GetStringAsync("http://api.vk.com/method/wall.get?v=5.45&filter=all&domain=sci&count=5");
 
                JObject json = JObject.Parse(resp);
 
                JArray items = (JArray)json["response"]["items"];
 
                JArray attachments = (JArray)items[0]["attachments"];
 
                JObject photo = (JObject)attachments[0]["photo"];
 
                var photoURL = photo["photo_604"].ToString();
 
                var imageByteArray = await client.GetByteArrayAsync(photoURL);
 
                pictureBoxPhoto.Image = byteArrayToImage(imageByteArray);
 
                // Count of items
                //textBoxOutput.Text += "count = " + items.Count.ToString();
            }
        }
 
        private Image byteArrayToImage(byte[] byteArrayIn)
        {
            using (var ms = new MemoryStream(byteArrayIn))
            {
                return Image.FromStream(ms);
            }
        }
    }
}

Оцени полезность:

13   голосов , оценка 3.769 из 5
Похожие ответы