开发者

How can i implement linkedin inviter to my website using PHP?

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 f开发者_JS百科or linkedin invitation in PHP. i would greatly be obliged .


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/


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:

  1. 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.

  2. 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜