dducro / php-api Goto Github PK
View Code? Open in Web Editor NEWThis project forked from ns-api/php-api
Implementatie van NS API in PHP
License: GNU General Public License v3.0
This project forked from ns-api/php-api
Implementatie van NS API in PHP
License: GNU General Public License v3.0
phpNS, by Jurrie Overgoor <[email protected]> phpNS is an implementation of the public API of the NS. You can find the documentation of that API at http://www.ns.nl/reizigers/blind/_api-nieuw phpNS is licensed under the GNU General Public License version 3. Please see the COPYING file for more information. Developer key ------------- To use phpNS, you must have a developer key. You can request one at https://www.ns.nl/ews-aanvraagformulier/ How to use phpNS ---------------- Step 1: get your developer key at https://www.ns.nl/ews-aanvraagformulier/ Step 2: include the main file Simply include phpNS.php with the following line: require_once('NS.php'); Step 3: decide on the retriever implementation you want to use A 'retriever' is a class that can request content from ns.nl. At the moment, there's only one retriever: * cURLRetriever: It uses cURL to request the information. (Implement your own retriever when you have special needs, like proxy-support or something. To implement your own retriever, extend Retriever and implement the abstract methods.) Instantiate the cURLRetriever like so: $retriever = new cURLRetriever('<YOUR_EMAIL>', '<YOUR_DEVELOPER_KEY>'); Replace <YOUR_EMAIL> with the email you used in step 1, and <YOUR_DEVELOPER_KEY> with the key you got from step 1. Step 4: decide on the caching implementation Caching the responses is a good idea, as it lowers the amount of requests you need to do on the NS servers. At the moment, you have the choice between three caching implementations: * NoCache: does not actually cache * FileCache: caches responses on disk, in a directory structure * MySQLCache: caches responses in a MySQL database table Let's go for the FileCache. We want to cache the responses in a 'tmp' directory below the current directory. We instantiate the FileCache like so: require_once('cache/FileCache.php'); $cache = new FileCache($retriever, "tmp"); Step 5: create an NS object The NS class is the main class that you'll use for accessing the NS information. Instantiate it like so: $ns = new NS($cache); Step 6: query the NS object for the information you want! The NS class has several methods. For this example, we want to retrieve a list of all stations: $stations = $ns->getStations(); The complete code is like this: require_once('NS.php'); require_once('cache/FileCache.php'); $retriever = new cURLRetriever('<YOUR_EMAIL>', '<YOUR_DEVELOPER_KEY>'); $cache = new FileCache($retriever, "tmp"); $ns = new NS($cache); $stations = $ns->getStations();
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.