Google Reader API - получение фидов

Кто-нибудь знает, есть ли вызов службы Google Reader, который пользователь может сделать, чтобы получить имя / uri всех каналов, подпадающих под определенный ярлык / категорию? Спасибо!


person r2rajan    schedule 09.12.2010    source источник
comment
Вы хотите, чтобы он возвращал их на основе логина? или вообще для обнаружения кормов?   -  person smilbandit    schedule 10.12.2010


Ответы (1)


Вы можете использовать вариант приведенного ниже кода, чтобы получить доступ к системе Google Reader. Вам нужно отправлять заголовок («Авторизация», «auth =» + myauthvar) с каждым запросом. Для редактирования элементов вам понадобится токен, который я также демонстрирую ниже. Как только у вас будет идентификатор аутентификации, вы можете опубликовать (с неповрежденным заголовком) в http://www.google.com/reader/api/0/subscription/list?output=xml, чтобы вернуть полный список подписок.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;

namespace ConsoleApplication2
{
    class Program
    {

        static void Main(string[] args)
        {
            getAuth();

            Console.ReadLine();
        }

        public static void getAuth()
        {

            //put in the username and password
            string postData = "[email protected]&Passwd=YOURPASSWORD&service=reader&source=some-uniqueapp-v1";

            WebRequest authReq = WebRequest.Create("https://www.google.com/accounts/ClientLogin");
            authReq.ContentType = "application/x-www-form-urlencoded";
            authReq.Method = "POST";

            byte[] bytes = Encoding.ASCII.GetBytes(postData);
            authReq.ContentLength = bytes.Length;
            Stream os = authReq.GetRequestStream();
            os.Write(bytes, 0, bytes.Length);

            WebResponse resp = authReq.GetResponse();

            StreamReader sr = new StreamReader(resp.GetResponseStream());

            string responseContent = sr.ReadToEnd().Trim();

            string[] responseSpilt = responseContent.Split('=');

            string authticket = responseSpilt[3];

            Console.WriteLine("Auth = " + authticket);

            sr.Close();

            getToken(authticket);

        }

        public static void getToken(string auth)
        {

            WebRequest tokenReq = WebRequest.Create("https://www.google.com/reader/api/0/token");
            tokenReq.ContentType = "application/x-www-form-urlendcoded";
            tokenReq.Method = "GET";

            tokenReq.Headers.Add("Authorization", "GoogleLogin auth=" + auth);

            WebResponse response = tokenReq.GetResponse();
            if (response == null) return;

            StreamReader sr = new StreamReader(response.GetResponseStream());
            string respContent = sr.ReadToEnd().Trim();

            string[] respSplit = respContent.Split('/');

            string token = respSplit[2];

            Console.WriteLine(" ");

            Console.WriteLine("Token = " + token);

            sr.Close();

        }
    }
}
person Jake Sankey    schedule 08.04.2011