How to consume a DHL API (Germany) - php

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

Related

Crawling play store in core php

I would like to know whether there is any way to crawl the google play store using package url in core php. I want to get the app rating and icon of the particular package url from the play store.
Can anyone help me to do this..??
Check out https://42matters.com/api/lookup They have an open source api that should return just about anything you want and return it in a JSON format. It also has an iOS part as well if you want to crawl that as well!
After you register on the website you will be provided with an Access Token. You need this to build your requests. To get the data on an specific package name, you build the link as this:
https://42matters.com/api/1/apps/lookup.json?access_token=?&p=
NOTE: It must be the PACKAGE NAME, not the title of the app, for example, the package name of Clash of Clans is com.supercell.clashofclans. You can obtain the package name by performing a search through their website as well. That link would be built as such:
https://42matters.com/api/1/apps/search.json?access_token=?q= Where query would be clash of clans!
If you use Google Chrome, give PostMan a try, its great for testing API's!
Hopefully this helps you out, if you need anymore help, let me know and I'll be glad to help you!

Searching twitters public timeline using JQuery

So a while back I used to use the twitter json search in one of my apps but it seems since the change in API versions there has been some major changes which even after reading the documentation I still can't get my head around and it really doesn't make it very easy to understand so hopefully one of you tech guys out there can help me out.
I want to clean my application up so it works again in plainly doing the following:-
http://search.twitter.com/search.json?
q='+param+'&
rpp=100&
result_type=recent&
lang=en
Obviously with the changes this is no longer possible but I want to be able to do this again using the new address but in JQuery unless someone can suggest either a tutorial or a piece of code or even a link to a topic where I could get my answer. I'm also open to using PHP as this is what I used at one point with searching Facebook's timeline and you can get an access token using $.get() for Facebook so surely it would be the same with Twitter too?
Any advice/code is welcome.
Thanks!
the search API needs authorization now. I'd say that, first off, you need to call the https url not http.
With Abhramam William's library you'd do something like the following, after having received your app's bearer token:
$your_tweets = $connection->get("https://api.twitter.com/1.1/search/tweets.json?q=from:grey_mina&result_type=recent&count=5");

Google Calendar API - Not showing calendar

I've downloaded the Google API Client and installed it on my Server. I set up my API and my client ID.
I configured the PHP file and now I'm trying to open it:
http://euotm.net/google-api-php-client/examples/calendar/simple.php
I signin using a Google Account, but then all I get is a code.
WHy does that happen? I need it to show a calendar.
I'm new to this API, so I really don't know much.
Thanks ahead,
Tom.
Indeed google calendar api doesn't provide a display widget to integrate calendar to your application. The api only gives you the possibility to retrieve every details about your calendars and their events, and then you'll have to find a way to display it on your screen if you want a nice layout.
have you
require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_CalendarService.php';
these files in your code ? i think you may miss it. what error, you are getting kindly make more sense about this
I am having the same issue. From what I've found so far, it looks like RadASM is right, but I was wondering what you moved on to in terms of which widget/gadget you used to display your actual calendar.
If you haven't found it yet, you may be looking for this:
https://developers.google.com/google-apps/calendar/gadgets/event/
Please let me know what you went with.
RadASM is right. Google Calendar API provides well structured data for the calendars and calendar events, allowing data manipulation, too. Desiring your custom layout, you need to take care of it.
Here is a detailed explanatory article with full demo code within a single HTML file - Easy and compact access to your Google calendars.

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

what are my options of pulling data from 3rd party website using php?

I would like to grab data from a certain website periodically (every 2-3 hours).
Website is weather related: http://meteo.gov.ge/index.php?l=2&pg=cm&ct=1&cm=
They also provide widget: http://meteo.gov.ge/index.php?pg=sb but I need something more personalized on my webpage... I only need to grab temperature in number and weather icon for any city.
On my ubuntu: I would probably try to use curl + grep/regex and cron it.
But how would I do that in php? Can I use in anyway the fact that they provide widget (I doubt, since it is embedded in image)?
p.s. this is not content stealing, it is a gov site thus financed by my (tax payer) money! I should be able to grab data I need, from service I pay for >:)
Tipically this kind of weather services offer RESTFUL web services (API) to get data:
You execute an http GET or POST providing some parameters (for example the name of the city you want to retreive weather forecasts) and they send you a piece of xml with the detailed forecasts.
Then is up to you to parse the returned xml and disply only the info you want.
I absolutely discourage you to grub the entire html content of the homepage of the weather site you shared.
Image they suddently change the structure of the page,dimensions and so on, your code will fail.
You need a structred way to get the forecasts, this is why API exists. If the site doesn't provide you API try to search another weather forecast site for your country!

Categories