wimkumpen/wit-php-sdk

This is a php sdk for the wit.ai API

1.0.0 2016-04-20 09:57 UTC

This package is not auto-updated.

Last update: 2024-03-22 16:58:58 UTC


README

This is a php sdk for the wit.ai API. It's a slim version of the Facebook PHP SDK. Still work in progress... Only supports curl at this moment.

Setup:

Add a composer.json file to your project:

{
  "require": {
      "wimkumpen/wit-php-sdk": "1.0.*"
  }
}

Then provided you have composer installed, you can run the following command:

$ composer.phar install

That will fetch the library and its dependencies inside your vendor folder. Then you can add the following to your .php files in order to use the library

require_once __DIR__.'/vendor/autoload.php';

Then you need to use the relevant classes, for example:

use Wit\Wit;

Basic usage:

use Wit\Wit;
$app = new Wit(array(
    'default_access_token' => 'your_access_token')
);

$response = $app->get('/intents');
var_dump($response->getDecodedBody());

$data = [
    "name" => "flight_request",
    "doc"  => "detect flight request",
    "expressions" => [
        ["body" => "fly from incheon to sfo"],
        ["body" => "I want to fly from london to sfo"],
        ["body" => "need a flight from paris to tokyo"],
    ]
];

$response = $app->post('/intents', $data);
var_dump($response->getDecodedBody());

Todo: