8

Google Contacts Data Api を使用して、こちらのドキュメントに従ってすべてのユーザーの連絡先を取得していますhttps://developers.google.com/google-apps/contacts/v3/

最初に、Google Auth を使用して、次のコードを使用してアプリケーションに対してユーザーを認証しました

string authSubUrl = AuthSubUtil.getRequestUrl("http://localhost:62439/ContactImporter/GoogleContacts.aspx", "https://www.google.com/m8/feeds/", true, true);
    Response.Redirect(authSubUrl);

ユーザーが正常にログインしてから2番目に、Googleから提供されたリクエストトークンを使用してGoogleContacts.aspxページにリダイレクトし、次のコードで連絡先を取得しようとしています

if (!string.IsNullOrEmpty(Request["token"]))
{
    GAuthSubRequestFactory authFactory = new GAuthSubRequestFactory("cp", "alpha");   
    RequestSettings rs = new Google.GData.Client.RequestSettings("alpha",Request["token"]);
    ContactsRequest cr = new ContactsRequest(rs);

    Feed<Contact> f = cr.GetContacts();

    foreach (Contact entry in f.Entries)
    {
        foreach (EMail email in entry.Emails)
        {
            Response.Write("\n" + email.Address);
        }
    }
}

そのコードは約4または5日から機能していましたが、現在は機能しておらず、次のエラーが表示されます

リモート サーバーがエラーを返しました: (401) 権限がありません。Google.GData.Client.GDataRequest.Execute() で Google.GData.Client.GDataGAuthRequest.Execute(Int32 retryCounter) で Google.GData.Client.GDataGAuthRequest.Execute() で Google.GData.Client.Service.Query(Uri Google.GData.Client.Service.Query(Uri queryUri, DateTime ifModifiedSince) の Google.GData.Client.Service.Query(FeedQuery feedQuery) の Google.GData.Client.Feed1.get_AtomFeed() at Google.GData.Client.Feed1.d__0.MoveNext() at GoogleContacts.Page_Load(Object sender, EventArgs e) in d:\Working Folder\API's\ContactImporter\GoogleContacts.aspx.cs:line 25 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp 、オブジェクト o、オブジェクト t、EventArgs e) で System.Web.Util.CalliEventHandlerDelegateProxy.Callback(オブジェクト送信者、EventArgs e) で System.Web.UI.Control.OnLoad(EventArgs e) で System.Web.UI.Control. System.Web.UI.Page.ProcessRequestMain の LoadRecursive() (ブール値 includeStagesBeforeAsyncPoint、ブール値 includeStagesAfterAsyncPoint)

そのエラーを解決する方法について何か提案はありますか?

4

1 に答える 1

2

これはあなたが探している答えではありませんが、私はあなたの心を休ませることができます. コードに問題はありません。Google は最近、連絡先 API サービスを予告なしに停止しました。彼らがそれを時代遅れにしたのか、それとも他の理由で取り下げたのかは誰にもわかりません. 昨日の時点で、彼らは API ドキュメントまで削除しました。ただし、それへのリンクはまだhttps://developers.google.com/google-apps/app-apisのAPIのリストに投稿されています.シャットダウン。うまくいけば、それは永続的なものではありません。この問題について、Google はまだ開発者に回答していません。

于 2013-03-29T00:48:28.193 に答える