PHP - Parse feed update from PubSubHubHub AppSpot Protocol - php

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

Related

How to consume a DHL API (Germany)

I am trying to track a shipment to get the status and date of it. For that I was checking the DHL documentation from the site in Germany, but is not really good to be honest.
Anyways, there's a testsuite which I downloaded and read, and there they say:
If you are working with the GET method, you can also view the link,
all necessary information is contained in the URL.
Here you will find the complete URL as the first entry:
GET
https://cig.dhl.de/services/sandbox/rest/sendungsverfolgung?xml=%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%20standalone%3D%22no%22%3F%3E%20%3Cdata%20appname%3D%22zt12345%22%20language-code%3D%22de%22%20password%3D%22geheim%22%20piece-code%3D%2200340434161094015902%22%20request%3D%22d-get-piece-detail%22%2F%3E%20
HTTP/1.1
You can also put this link into your browser. (doing that doesn't work for me)
That link supposed to output in XML format.
So my question is...How can I get the info from that URL in PHP? to then be able to retrieve the specific info in it.
I think the best way will be to use this library which implements the DHL API methods quite well:
https://github.com/alfallouji/DHL-API
You might also refer to this post where they discuss different ways of using the API:
DHL Tracking Api and PHP

How to fetch data from external site to own site

I want to fetch data from live stock market to my web site. By using php and jQuery.
Has the source got an API you can work with to fetch the data? If so read their docs and implement it.
If not you could possibly do a Curl request and parse the data you need if your allowed.
More importantly you need to be more specific with your question if you want to get good answers, if any at all :-).
You need to find a web service that offers a stock market feed in the form of JSON or XML, so that your computer would be able to parse it. Not a website. Most of those feeds are paid - especially those that are close to real-time.
Then, once you have such a feed, you should be able to access it via your browser - just by typing in the URL. For example, http://www.quotewebsite.com/symbol=MSFT
This will help you understand what your server side script is supposed to do. Then, in your PHP script (PHP is a server-side programming language), issue a CURL request to download that specific page into your website's database (ex. MySQL). This will allow you to have historical data inside your own system. Then you get to render that data back to your own customers by querying your own database.

Posting Data to Amazon using curl

when we enter a keyword (search term) in amazon kindle book store, search brings a list of books back.
I am trying to scrap the above said amazon kindle book search, i have some basic/usage idea of CURL in php, but i have never posted variables using curl. I tried at my level. but havent succeeded yet. the only thing i know is i should post "key-word" variable to amazon and should grab the result.
The problem with this step is that the key-word is submited to the form and only a part of the page is refreshed everytime key-word is entered.
can somebody help me telling the step required?
which data i will need to post icluding key-word? how can i know about
the header /user agent required for this? what information will be required for this process? which elements will be posted ?
I have tried using fiddler but as i am new to it, i am not getting the concepts.
The link i want to parse is amazon.com
Guideline please, if i get the what needs to be posted, i think i will be able to do the curl process.

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

Retrieve the formated URL from open_id form

I just added OpenID to my website using the PHP janrain libraries, and I got everything working but I have a question about how to do something.
After receiving the openid_url from the user, I pass it to the openid lib, which then processes the url and gets it ready to send to the OP. How can I retrieve that URL?
Why I ask is because my script currently sees http://mysite.com and mysite.com as different URLs. I know the library normalizes the URL, I just don't know how to extract it.
I hope I made sense, and thank you for helping.
You get the final URL you want to use for tracking purposes back with a Auth_OpenID_SuccessResponse object, in the claimed_id attribute. (The getDisplayIdentifier() method outputs a version more intended for human consumption, which may or may not be different.)

Categories