[ckan-dev] Using CKAN's API via PHP.
Paolo Mainardi
paolo at twinbit.it
Mon Sep 29 08:19:58 UTC 2014
As is written in the wiki:
https://github.com/ckan/ckan/wiki/CKAN-API-Clients you can use those
clients:
- Ckan_client-PHP: https://github.com/jeffreybarke/Ckan_client-PHP
- PHP CKAN client - from Silex. Uses Guzzle for the HTTP. Packaged using
Composer; also on Github. Covers a number of action functions for
reading/writing packages, resources, etc. Comes with tests (
https://packagist.org/packages/silex/ckan_client)
Thanks,
P.
On Mon, Sep 29, 2014 at 9:52 AM, Henrik Aagaard Jørgensen <
henrikaagaardjorgensen at gmail.com> wrote:
> Hello everyone,
>
> I'm trying to use CKAN's API via PHP.
>
> I'm using cURL and are allowed if the dataset is not private. But when
> trying to access a private dataset I get access denied.
>
> CKAN is version 2.2 with datastore installed.
>
> Running this code fails with response from the CKAN API with
> "{'permissions': ['Not authorized to read resource.']}":
>
> -----
>
> $sql = 'SELECT * FROM "656eedf2-8648-442d-90fa-4500fc49eb4a"';
>
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_URL, "
> http://localhost/api/action/datastore_search_sql");
> curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array('sql' => $sql)));
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
> curl_setopt($ch, CURLOPT_HTTPHEADER, Authorization'array(' =>
> 'b5256727-2711-4ac5-9009-cfc155ec13a2'));
> $response = curl_exec($ch);
> curl_close($ch);
>
> var_dump(json_decode($response));
>
> -----
>
> When I use the code on public datasets it works. The API-key I'm using is
> the same as the user who created it, and I'm able to see it via the web
> interface.
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>
>
--
[image: Twinbit] <http://www.twinbit.it>
Paolo Mainardi
*Twinbit Founder - CTO*
*www*: twinbit.it
*mobile*: (+39) 3401678089
*skype*: paolo_mainardi
*linkedin*: paolomainardi <http://www.linkedin.com/in/paolomainardi>
*twitter*: @paolomainardi <http://twitter.com/paolomainardi>
*blog*: paolomainardi.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20140929/997ebf9d/attachment-0003.html>
More information about the ckan-dev
mailing list