How can i implement linkedin inviter to my website using PHP? - 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 for 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:
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

Related

Adding url to nofitications

I'm using phonegap build to create an app.
I've used a plugin for collection ids for sending push notifications, and also a plugin to register url schemes.
I have decided to use Google GCM service to send the notifications (I'm using PHP on the server).
When I create the notification message I can send the title and the message in the data json. But I also want to include a url for deep linking, something like:
myweirdapp://show.html?uid=467
How can I do that?
Thanks !
Use data json field to put your custom data in. See https://developers.google.com/cloud-messaging/server-ref#downstream
The WonderBird answer is almost correct.
You do need to add the data to the Json you are sending to GCM.
Then in your app you need to read this data if the notification was pressed and parse the result.
For instance, let's say you wanted to refer users to a different page. For this you have added to the Json the variable page=somepage.html
In the app you have to check if e.coldstart is true and then do something like location.href=e.payload.page
It's importent to notice that page is inside payload but coldstart is not.

Pull api information without refreshing the page

I have a form that will be posted to a PHP method. However before it is posted I want to pull some information from a 3rd party api service that returns an xml and use that xml to populate my <select> box.
Mostly I was thinking I would be doing this using JS but it turns out Same Origin policy denies pulling xml from remote apis. So now Im stuck.
I render the HTML form user inputs their api credentials the press the button pull data this should call a JS method that would parse the XML from the API and then populate the <select> box on the form and then the user can submit the form it self.
How can I go about this if the API only serves XML and JS has the Same Origin Policy.
You cannot make cross domain AJAX calls for XML... There are some work arounds though. Try this out..
http://benalman.com/projects/php-simple-proxy/
Please check it out, HTML5 CORS methods
http://www.html5rocks.com/en/tutorials/cors/

PHP - Parse feed update from PubSubHubHub AppSpot Protocol

I am using https://pubsubhubbub.appspot.com/ to subscribe to feeds through well know PubSubHubHub protocol implementation.
I have subscribed to required topic from the following page:
https ://pubsubhubbub.appspot.com/subscribe
I received subscription verification, and I succesfully responded with hub.challenge received in $_GET parameters. I have seen my logs of web server, it shows that POST request of notifications sent fron hub:
http://i.stack.imgur.com/LH44O.png
I have my code setup, which stores any key=>value pairs from $_POST and $_GET in my DB. It has been tested, and works perfectly well.
Q: Is there anyway to know, how the hub is sending the notification feed? (it's not in GET or POST for sure) and how I can parse it in PHP?
I have studied working draft of the protocol as well, unable to figure out something that might work.
https://pubsubhubbub.googlecode.com/git/pubsubhubbub-core-0.4.html#contentdistribution
Have searched through code samples as well, too much complex code and it does not make any sense to me, how I can translate it to simple PHP parse code. (I think links will help you)
https://code.google.com/p/pubsubhubbub/wiki/SubscriberClients
https://code.google.com/p/pubsubhubbub/source/browse/
I luckily had time to do some more research on this problem and also found some relevant results that helped. Just want to share the results here, so that anyone following in future can find resolution to this issue.
The PubSubHubHub.AppSpot hub sends feed update notification instantly via POST along with part of updated feed as part of body text. So, it gets simple to get the updated feed and parse in any language. Just extract page body and parse RSS-xml present as body text.
I wrote following script in PHP to get the updated feed text:
$request_body = #file_get_contents('php://input');
The $request_body contains RSS-xml for updated feed. Process it, and store any information you want out of RSS-xml feed.
Thanks.
Reference link: (that suggested me simple solution)
Pubsubhubbub subscriber callback implementation in PHP

Howto use FB Graph to post a message on a page feed

I have created an app, and now i want to post a message on one of my pages wall with use of the new Graph API. Is this do-able?
below is the steps which i do
Using this to Get access code
https://www.facebook.com/dialog/oauth?client_id=1498653617947&redirect_uri=https://apps.facebook.com/post_on__my_page/index2.html&scope=email,read_stream,publish_stream,manage_pages,offline_access
Than use this to get access token
https://graph.facebook.com/oauth/access_token?client_id=1498653617947&redirect_uri=https://apps.facebook.com/post_on__my_page/index2.html&client_secret=seceret&code=AQDCqJNJnCvnFKVdbCyTp2vfzbT0ADbNgYsQ_2YtDdC_O2aIOwvkjx52HNcp3uiuBANJqOhb_M2sptB-lRrIECZxi5kZpzljez1J1oOtTp25gTnNDmV-RCVvR97DMiRAprNtwUBcstAotjsyYo5cNwJCWnkcgNigwhbQtE5Jp22sluVcZKhnO43cWQE#_=_
Now get page id and page access token from below
https://graph.facebook.com/me/accounts/?access_token=the_access_token_above
*use this to post on my page *
https://graph.facebook.com/1916117518646/feed?message:testmessage&access_token=aceess_token
any one please explain which point is wrong because instead of posting is just show posts details
i found that some thing wrong in this below code any one please suggest what and how to do
https://graph.facebook.com/1916117518646/feed?message:testmessage&access_token=aceess_token
I always highly suggest to people experimenting around for the first time to use the Graph API Explorer tool. It helps solidify the structure of the Graph and how to access it. See https://developers.facebook.com/tools/explorer
Another thing I always recommend is to lint the access_token you are trying to use. See https://developers.facebook.com/tools/lint. This is to ensure you have the right token with the correct permissions.
Also the access_token you use to post to a page must be a page token and not a user token. In your above example, it's unclear as to which one you're using since you've named both the same. I know you said you're using it, but with that variable name being the same, I always wonder.
Also the you need to do an HTTP Post and not an HTTP get to post a message. Again, play around in the graph API explorer until you can do it there. Once you've done it there, it's fairly trivial to do it with one of the SDKs.
You need to perform POST request, not GET, and pass parameters in POST body, not in the url
http://developers.facebook.com/docs/reference/api/user/#posts
http://facebook.stackoverflow.com/questions/691425/how-do-you-post-to-the-wall-on-a-facebook-page-not-profile

zend - upload file with REST services

i use zend framework and work with some web services(insert, update, delete but with int, string parameters). Now i don't how to upload file(for example image) with zend and web services(REST). Does anyone have some example?
You should send the file throught post call. The Rest service will receive the postAction as when you do what ever other functions. But, with files you cannot make the calls with ajax, so you have a little trick to do in client side.
Remember, REST service will implement post action and receive the parameters as you would receive normally. If you know how to receive and manipulate a file with standard php, you can do it in REST service implementation.
The trick on client side is to create an invisible iFrame and redirect the submit form target to it.
This links explain this method very well with code samples:
form POST in iframe without affecting history
http://ajaxpatterns.org/IFrame_Call
http://geekswithblogs.net/rashid/archive/2007/08/01/Create-An-Ajax-Style-File-Upload.aspx
http://www.openjs.com/articles/ajax/ajax_file_upload/
http://viralpatel.net/blogs/2008/11/ajax-style-file-uploading-using-hidden-iframe.html
NamastĂȘ !!

Categories