0

任何人都可以指导我如何在 c# asp.net 中使用 Linkedin Invitation API 解决问题。我想通过此 api 从我的应用程序向特定用户发送邀请,但找不到任何足够的信息来启动它。谁能给我一些例子。我已经从linkedin search api获取了用户列表。现在我想向这些用户发送邀请。

先谢谢了。希望最好的答案出来。

谢谢

4

1 回答 1

0

最后,它完成了。我已经用asp.net c#成功实现了linkedin邀请api。我在这里发布示例代码,供其他想要实现它的用户使用。

try
{
     string uid=uniqueid of user,to whom you want to send request.
     // if you get this user bysearch api or 1st connection, then from http-header response, you will find value field. split this value by ':' and store in two variable
     string name=splitvalue1;
     string namevalue=splitvalue2;
     string xml = "<?xml version='1.0' encoding='UTF-8'?><mailbox-item><recipients><recipient><person path=\"/people/id=" + uid + "\" /></recipient></recipients>";
     xml += "<subject>Invitation to Connect</subject>";
     xml += "<body>Please join my professional network on LinkedIn.</body>";
     xml += "<item-content><invitation-request><connect-type>friend</connect-type><authorization><name>" + name + "</name><value>" + namevalue + "</value></authorization></invitation-request></item-content></mailbox-item>";
     string accessCodeUri = "https://api.linkedin.com/v1/people/~/mailbox?oauth2_access_token=" + Session["accessCode"]; // this is session value which you get on authorization success return by linkedin
     WebRequest request = WebRequest.Create(accessCodeUri);
     request.Method = "POST";
     request.ContentType = "application/xml";
     request.ContentLength = xml.Length;
     StreamWriter requestWriter = new StreamWriter(request.GetRequestStream(),   System.Text.Encoding.ASCII);
     requestWriter.Write(xml);
     requestWriter.Close();
     WebResponse webResponse = request.GetResponse();
     //success
}
catch(WebException exc)
{
}

希望它可以帮助其他人。

于 2013-10-15T07:00:37.933 回答