java - Google Reader API - 获取提要

标签 java feed google-reader

有谁知道用户是否可以调用 Google 阅读器服务来获取属于特定标签/类别的所有提要的名称/uri?谢谢!

最佳答案

您可以使用以下代码的变体来访问 Google 阅读器系统。您需要在每个请求中发送 header ("Authorization", "auth="+myauthvar)。为了编辑项目,您将需要我也在下面演示的 token 。获得授权 ID 后,您可以将(标题完好无损)发布到 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=YOURUSERNAME@gmail.com&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();

        }
    }
}

关于java - Google Reader API - 获取提要,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4400893/

相关文章:

icons - 如何访问 Google/Gmail/Gchat/Reader 用户图标

java - windowActivated 和 windowFocusGained 之间的区别

用于维基百科的 JAVA API

java - Android游戏java boolean 解决方案

javascript - Google Feed API 导致页面空白

drupal - 如何从 libsyn rss feed 播放音频播客文件? (德鲁帕尔)

Facebook 页面的帖子提要

java - Google Reader 编辑 API 身份验证问题

java - Eclipse 从哪里获取 ${user} ?

google-reader - 如何标记使用谷歌阅读器 API 阅读的项目?