簡體   English   中英

解析Linkedin API調用

[英]Parse Linkedin API call

這是Mainviewcontroller中的外觀。

我有兩個單獨的類,LinkedInUser和_User。 accessToken存儲在LinkedInUser中,而不存儲在_User中。 LinkedInUser類中有一個名為“ user”的指針,該指針指向_User中的“ objectID”。 我想從LinkedInUser檢索accessToken,但是超時我嘗試查詢不返回任何結果,當我運行下面的代碼時,結果為null。 我在做什么錯,我該如何解決?

  [PFLinkedInUtils logInWithBlock:^(PFUser *user, NSError *error) {
    NSLog(@"User: %@, Error: %@", user, error);

    PFObject *linkedin = [PFObject objectWithClassName:@"LinkedInUser"];

    NSString *accessToken = linkedin[@"accessToken"];

        [PFLinkedInUtils.linkedInHttpClient GET:[NSString stringWithFormat:@"https://api.linkedin.com/v1/people/~:(blahblahblah)?oauth2_access_token=%@&format=json", accessToken] parameters:nil success:^(AFHTTPRequestOperation *operation, id result)

這行:

PFObject *linkedin = [PFObject objectWithClassName:@"LinkedInUser"];

正在創建LinkedInUser對象的新實例。 它沒有accessToken屬性的值。 相反,您應該向Parse查詢與用戶關聯的現有對象。

另外,如果您能夠稍微更改數據模型,則在_User具有引用LinkedInUser的指針可能會更好。 這樣,您可以直接獲取該對象,而不必進行其他查詢。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM