2014-03-25 48 views
0

我通過使用GData Obcective-C Client進行身份驗證並從中獲取聯繫人,將gmail集成到我的應用中。對於身份驗證,我使用gtm-oauth2,這部分工作非常好。獲取GDataEntryBase而不是GDataEntryContact然後嘗試獲取谷歌聯繫人

我對GTMOAuth2ViewControllerTouch初始化範圍:

NSString *scope = [NSString stringWithFormat:@"https://www.googleapis.com/auth/plus.me %@", [GDataServiceGoogleContact authorizationScope]]; 

驗證初始化:

__keychainItemName = [infoPlist objectForKey:@"GoogleKeyChainItem"]; 

__auth = [GTMOAuth2ViewControllerTouch 
        authForGoogleFromKeychainForName:__keychainItemName 
        clientID:[infoPlist objectForKey:@"GoogleClientID"] 
        clientSecret:[infoPlist objectForKey:@"GoogleClientSecret"]]; 

對於GData建築我用這個博客(含圖​​片和東西)

http://hoishing.wordpress.com/2011/08/23/gdata-objective-c-client-setup-in-xcode-4/

GData我g等從谷歌庫,只需在控制檯中運行這個

# Non-members may check out a read-only working copy anonymously over HTTP. 
svn checkout http://gdata-objectivec-client.googlecode.com/svn/trunk/ gdata-objectivec-client-read-only 

問題開始當我試圖讓聯繫人:

- (GDataServiceGoogleContact *)contactService { 

    static GDataServiceGoogleContact* service = nil; 

    if (!service) { 
     service = [[GDataServiceGoogleContact alloc] init]; 
     [service setShouldCacheResponseData:YES]; 
     [service setServiceShouldFollowNextLinks:YES]; 
     [service setAuthorizer:__auth]; 
    } 

    return service; 
} 

- (void) methodExecute { 
    GDataServiceGoogleContact *service = [self contactService]; 

    GDataServiceTicket *ticket; 

    const int kBuncha = 2000; 

    NSURL *feedURL = [GDataServiceGoogleContact contactFeedURLForUserID:kGDataServiceDefaultUser]; 

    GDataQueryContact *query = [GDataQueryContact contactQueryWithFeedURL:feedURL]; 
    [query setShouldShowDeleted:NO]; 
    [query setMaxResults:kBuncha]; 

    [ticket setAuthorizer:__auth]; 

    ticket = [service fetchFeedWithQuery:query 
           delegate:self 
    didFinishSelector:@selector(contactsFetchTicket:finishedWithFeed:error:)]; 
} 

- (void)contactsFetchTicket:(GDataServiceTicket *)ticket 
      finishedWithFeed:(GDataFeedContact *)feed 
         error:(NSError *)error { 

    if(error != nil){ 
     NSLog(@"%@\n\n\n%@", error, feed); 
    } 
    else{ 
     NSLog(@"%@\n\n\n%@", error, feed.entries); 
    } 
} 

這裏是點 - 而不是GDataEntryContact它必須在feed,我得到了GDataEntryBase對象的數組。有對象描述例如:

GDataEntryBase 0xb3b2300: {v:3.1 title:John Jackson etag:"Rn4_fjVSLit***." 
categories:1 links:photo,self,edit edited:2013-03-14T17:55:57Z 
id:http://www.google.com/m8/feeds/contacts/myemail%40gmail.com/base/kindofid 
unparsed:<gContact:groupMembershipInfo>,<gd:name>,<gd:phoneNumber>} 

我試圖取代SVN GDataThis GData version,但一切都沒有用。我處於邊緣。

順便說一下,我也在谷歌控制檯上關閉了選項Contacts API,並在Other C Flags中增加了-DGDATA_INCLUDE_CONTACTS_SERVICE=1,GData

我錯過了什麼或只是愚蠢?

非常感謝您的回覆!

回答

0

我只爲項目輸入了其他鏈接器標誌,並且由於某種原因,它們不適用於整個目標。