我实现了使用LinkedIn社会样本登录,并使用Github Cloudrail-Xamarin示例成功获取了ID,姓名,电子邮件,性别,PictureUrl,描述和出生日期。
documentation建议使用AdvancedRequestSpecification功能来请求LinkedIn个人资料的“教育”或“经验”部分。但是只举了一个保管箱的例子。
需要在AdvancedRequestSpecification中发送什么URL(“ URL转到此处”)以获取LinkedIn个人资料的“教育”或“经验”部分?
答案 0 :(得分:0)
据我所知,它应该是相同的URL,但是您需要申请“使用LinkedIn程序申请”才能获得完整的答复。以下是所有可用字段的列表:https://developer.linkedin.com/docs/fields
答案 1 :(得分:0)
最后,我能够在Android上获得一些额外的信息,但在iOS上却没有。
1)在PCL项目上,我添加了一个接口:
public interface ILinkedIn
{
Task<Model.LinkedInProfile> GetLinkedInProfile();
}
2)在Android项目上,我添加了以下依赖项服务的实现
public async Task<Model.LinkedInProfile> GetLinkedInProfile()
{
var profile = new Model.LinkedInProfile();
int numTries = 500;
var service = new LinkedIn(MainActivity.Instance, "blablabla", "blablabla");
new System.Threading.Thread(new System.Threading.ThreadStart(() =>
{
try
{
service.Login();
profile.Description = service.Description;
profile.ImageUrl = service.PictureURL;
var req = new AdvancedRequestSpecification("/people/~:(positions,public-profile-url)?format=json");
var res = service.AdvancedRequest(req);
profile.Exta = Newtonsoft.Json.JsonConvert.DeserializeObject<Model.ExtraProfile>(res.BodyAsString);
service.Logout();
}
catch
{
numTries = 0;
}
})).Start();
while (numTries-- > 0 && profile.Exta == null)
await Task.Delay(250);
return profile;
}
3)在iOS项目上,我添加了类似的Dependency服务实现
public async Task<Model.LinkedInProfile> GetLinkedInProfile()
{
var profile = new Model.LinkedInProfile();
int numTries = 500;
CRLinkedIn service = new CRLinkedIn("blablabla", "blablabla");
new System.Threading.Thread(new System.Threading.ThreadStart(() =>
{
try
{
service.Login();
profile.Description = service.GetProfileDescription();
profile.ImageUrl = service.GetPictureURL();
CRAdvancedRequestSpecification req = new CRAdvancedRequestSpecification("/people/~:(positions,public-profile-url)?format=json");
/* Edited to Add the next 3 lines as the cloudrail suggested fix for iOS */
req.Method = @"GET";
req.Headers = new Foundation.NSMutableDictionary();
req.SetBodyAsString("");
/* Finished Editing */
var res = service.AdvancedRequestWithSpecification(req);
profile.Exta = Newtonsoft.Json.JsonConvert.DeserializeObject<Model.ExtraProfile>(res.BodyAsString);
service.Logout();
}
catch
{
numTries = 0;
}
})).Start();
while (numTries-- > 0 && profile.Exta == null)
await Task.Delay(250);
return profile;
}
4)在Android上,它可以完美运行,但在iOS上,它会抛出异常:
注意:请参见上面的cloudrail修复程序
var res = service.AdvancedRequestWithSpecification(req);
说:
Objective-C异常抛出。名称:CRUnknownException原因:ServiceCode函数AdvancedRequestSupporter:advancedRequest在10时出错,[***-[NSMutableDictionary setObject:forKey:]:发送到未初始化的可变字典对象的方法] 本机堆栈跟踪:
希望能为解决iOS崩溃提供任何帮助。
感谢cloudrail支持