ios - Instagram 获取用户详细信息

标签 ios iphone objective-c oauth instagram

我正在尝试将 instagram 集成到我的应用程序中,在获取访问 token 后获取用户详细信息时,它显示错误。我在 NSData 中附加数据并尝试在 connectionDidFinishLoading(NSURLConnection *)connection ( NSURLConnection Delegate) 中打印它。在将 NSData 转换为 id 时,它显示为 null 。此外,如果我将 NSdata 转换为 NSString ,我将收到 Response as

    {"meta":{"error_type":"OAuthAccessTokenException","code":400,"error_message":"The   access_token provided is invalid."}}{"meta":{"code":200},"data":{"username":"XXXX","bio":"","website":"","profile_picture":"http:sampleiamge.jpg","full_name":"samplename","counts":{"media":1,"followed_by":0,"follows":0},"id":"sampleID"}}

如果将 json 打印为 id jsonData = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error]; 出现错误

Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Garbage at end.) UserInfo=0xa967bc0 {NSDebugDescription=Garbage at end.}

尝试了所有的 jsonreading 选项,但没有结果

任何帮助都是可观的。 谢谢

最佳答案

您还可以查看 InstagramKit,它相当直接地完成了这项工作。 https://github.com/shyambhat/InstagramKit 有一个演示应用程序,您可以通过几行代码了解如何完成身份验证并请求用户的详细信息。您真的不需要弄乱访问 token 数据格式。

关于ios - Instagram 获取用户详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22069751/

相关文章:

ios - xcode interface builder - 调整 View 大小或移动 View

ios - map View 总是移回用户的当前位置

ios - 提醒应用底层周 uiscrollview

ios - 如果 Watch 应用程序在 iPhone 应用程序运行之前打开,则不会填充任何数据

iphone - MPMoviePlayer 流式视频缓冲区大小

ios - Objective-C内存管理:什么时候使用`[variable release]`vs`variable = nil`来清理内存?

ios - Google Play游戏不允许用户加入回合制比赛

ios - 制作二进制计算器应用程序 (swift)

objective-c - 2008-02-01T10 :03:23. 793-06:00 的日期格式

iphone - NSCountedSet - 获取集合中的项目数