mcroitor / ckan-php-client

A PHP client for the CKAN data catalog, used by https://github.com/GSA/ckan-php-manager

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ckan-php-client

Build Status Codacy Badge Join the chat at https://gitter.im/GSA/ckan-php-client

Tiny CKAN API client written in PHP

Requirements

Installation

The recommended way to install is through composer.

And run these two commands to install it:

$ curl -sS https://getcomposer.org/installer | php -- --install-dir=bin

Create a composer.json file for your project:

{
    "repositories": [
        {
            "type": "git",
            "url": "https://github.com/GSA/ckan-php-client.git"
        }
    ],
    "require": {
        "gsa/ckan-php-client": "0.*"
    }
}

Install dependencies:

$ composer install

Now you can add the autoloader, and you will have access to the library:

<?php
require 'vendor/autoload.php';

Usage

<?php

use CKAN\CkanClient;

$apiUrl = 'http://catalog.data.gov/api/3/';          // CKAN API URL
$apiKey = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';   // CKAN API KEY, if needed / or null

$Ckan = new CkanClient($apiUrl, $apiKey);

$ckanResults = $Ckan->package_search('organization:irs-gov');
$ckanResults = json_decode($ckanResults, true);

Sample

Check GSA/ckan-php-manager script as an example

CKAN API DOCs

http://docs.ckan.org/en/latest/api/index.html

About

A PHP client for the CKAN data catalog, used by https://github.com/GSA/ckan-php-manager

License:GNU General Public License v3.0


Languages

Language:PHP 100.0%