1

I am using Google Contacts API to fetch gmail contacts from my ASP.NET application. After giving the username and password, the application doesnt respond and the connection gets timed out. Below is the error when I tried to debug:

Execution of request failed: http://www.google.com/m8/feeds/contacts/default/full

Snapshot of the error enter image description here

4

2 回答 2

0

请检查您的access_token是否有效。获取联系人列表作为定义 URL:

https://www.google.com/m8/feeds/contacts/default/full?alt=json&max-results=" + maxemails + "&oauth_token=access_token";

access_tokenGmail, 成功登录后提供。

于 2013-06-11T08:25:52.413 回答
0

你确定你的密码和用户是正确的吗?好吧,我会给你这段代码,它工作正常:


public DataSet GetGmailContacts(string p_name, string e_id, string psw)
{
    //p_name = name of your app; e_id = your gmail account; psw = password of your gmail account
    DataSet ds = new DataSet();
    DataTable dt = new DataTable();
    DataColumn dc1 = new DataColumn();
    dc1.DataType = Type.GetType("System.String");
    dc1.ColumnName = "emailid";
    DataColumn dc2 = new DataColumn();
    dc2.DataType = Type.GetType("System.String");
    dc2.ColumnName = "name";
    dt.Columns.Add(dc1);
    dt.Columns.Add(dc2);
    RequestSettings rs = new RequestSettings(p_name, e_id, psw);
    rs.AutoPaging = true;
    ContactsRequest cr = new ContactsRequest(rs);
    Feed<Contact> f = cr.GetContacts();
    int counter= 0;
    foreach (Contact t in f.Entries)
    {
        Name nombreContacto = t.Name;
        DataRow drx = dt.NewRow();
        drx["emailid"] = t.PrimaryEmail.Address.ToString();
        drx["name"] = t.Title.ToString();
        dt.Rows.Add(drx);
        counter++;
    }
    ds.Tables.Add(dt);
    Response.Write("Total:" + counter.ToString());
    return ds;

}

之后,您可以使用函数返回的数据集填充 Gridview。

于 2014-02-11T21:59:22.930 回答