我正在尝试将 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/