如何使用 PHP 在我的网站上实现 linkedin 邀请程序?
我从链接 http://developer.linkedin.com/docs/DOC 阅读 linkedin 邀请者的文档-1012 并且除了此页面之外,互联网上没有其他帮助。但我发现的只是这个页面上的 XML 内容。我不知道如何使用它以及基本上需要什么才能使代码正常工作。请发布或参考 PHP 中 linkedin 邀请的完整代码。我将非常感激。
i read the documentation of linkedin inviter from the link http://developer.linkedin.com/docs/DOC-1012 and there is no other help on internet inspite of this page. but what i found is only the XML things on this page. i dont know how to use it and what should be required basically to make the code work. please post or give reference to a complete code for linkedin invitation in PHP. i would greatly be obliged .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有一个 LinkedIn 推荐的 PHP 库,它具有您可以使用的特定 inform() 方法:
http ://developer.linkedin.com/docs/DOC-1255
代码直接链接:
http://code.google.com/p/simple-linkedinphp/
本质上,您向其传递邀请方法(通过电子邮件、会员 ID),向其传递收件人、主题、消息,它创建 XML 并通过 OAuth 将其发送到 LinkedIn。
还包含一个演示脚本,以及一个现场演示,展示如何使用 inform() 方法:
http://simplelinkedin。五十使命.net/
There is a LinkedIn-recommended library for PHP that has a specific invite() method that you could use:
http://developer.linkedin.com/docs/DOC-1255
Direct link to code:
http://code.google.com/p/simple-linkedinphp/
Essentially, you pass it the method of invitation (by email, member id), pass it the recipient, subject, message, and it creates the XML and sends it via OAuth to LinkedIn.
There's also a demo script included, and a live demo showing how to use the invite() method here:
http://simplelinkedin.fiftymission.net/
好的,我简单浏览了一下您正在谈论的 API。该 API 要求您首先构建一个 XML 文件,然后使用“POST”方法将其发送到提供的 URL。我应该提到的是,我以前从未尝试过这样做,所以我可能是不正确的,但这个过程似乎非常简单,尽管根据 LinkedIn API 文档有些令人困惑。
因此,您有多种选择:
我相信您可以使用 AJAX 将 XML 发布到 LinkedIn API。为此,您需要设置一个使用“POST”方法的 AJAX 调用。这里有一个关于如何构造 AJAX POST 请求的链接(它与“获取”请求)。因此,本质上,您可以将用户输入从表单中取出,将其打包到一系列结构化 XML 节点中(就像构建 XML 文件一样),然后获取动态生成的 XML 块并将其插入到表单的主体中。 AJAX 请求。发送请求,然后解析结果。
或者,您可以设置一个空白的 XML“模板”文件,其中包含向 LinkedIn API 提交邀请所需的结构。当您的用户向您的服务器提交邀请请求时,您将提取他们的输入,验证它,然后使用 PHP Xpath 和 PHP DOM 进行搜索通过您的 XML 模板并将用户数据动态添加到模板位于正确的节点位置。然后使用此页面上的说明将您的邀请请求发送至LinkedIn 的 API 处理程序(使用 PHP 函数“curl()”)。
让我知道结果如何!
问候,
H
OK I took a brief look at that API you are talking about. The API requires that you first build a XML file and then use the "POST" method to send it to the provided URL. I should mention that I have never attempted this before, so I may be incorrect, but the process seems pretty straightforward, if somewhat confusing according to the LinkedIn API docs.
So you have several options:
I believe that you can use AJAX to post the XML to the LinkedIn API. In order to do this, you would set up an AJAX call that uses the "POST" method. Here is a link on how to construct a AJAX POST request (its a little different than a "get" request). So essentially you would take your users input out of a form, pack it into a series of structured XML nodes (just like if you were building a XML file) and then take that dynamically generated block of XML and insert it into the body of the AJAX request. Send the request and then parse the results.
Alternatively you could set up a blank XML "template" file with the structure you need to submit the invitation to the LinkedIn API. When your user submits the invitation request to your server you would extract their input, validate it, and then use a combo of PHP Xpath and PHP DOM to search through your XML template and dynamically add the user data to the template at the correct node locations. Then use these instructions on this page to send your invitation request to the API handler at LinkedIn (uses PHP function "curl()").
Let me know how it turns out!
Regards,
H