项目作者: ylabonte

项目描述 :
PHP Dialogflow V2 API Example (DetectIntent method)
高级语言: PHP
项目地址: git://github.com/ylabonte/php-dialogflow.git
创建时间: 2019-02-05T03:22:43Z
项目社区:https://github.com/ylabonte/php-dialogflow

开源协议:The Unlicense

下载


PHP Dialogflow API

A working PHP Dialogflow V2 API example using the DetectIntent method (SessionsClient::detectIntent()).

Requirements

How to

  • Clone repo git clone https://bitbucket.org/labonte/php-dialogflow-api.git
  • Enter directory cd php-dialogflow-api
  • Use .env file or .htaccess file for configuration. Appropriate file templates can be found in the .env.dist and .htaccess.dist files.

For local testing (using a UNIX based OS)

  • Create .env cp .env.dist .env
  • Edit .env with your favorite editor (eg. vim .env)
  • Run composer install
  • Run php -S 127.0.0.1:8080 -t .

For “production” use (Using apache with mod_rewrite)

  • Copy .htaccess cp .htaccess.dist .htaccess
  • Edit .htaccess with your favorite editor (eg. vim .htaccess)
  • Run composer install --no-dev
  • Copy the following files and folders to your webserver
    • .htaccess (you have to create it first!)
    • DetectIntent.php
    • lib.php
    • vendor/
  • According to the .htaccess you must place your Google Account Credentials file in a save place on your server. It’s on you to ensure the file is not accessible from the web!

For use with nginx

Take a look into the .htaccess.dist file. You have to reproduce the those statements. The resulting config for your nginx location section should look something like this:

  1. location /DetectIntent {
  2. # Fill in!!!
  3. # Supply your Google Project ID and path to the credentials file.
  4. fastcgi_param GOOGLE_PROJECT_ID [YOUR PROJECT ID]
  5. fastcgi_param GOOGLE_APPLICATION_CREDENTIALS [YOUR GOOGLE APPLICATION CREDENTIALS FILE PATH]
  6. # Optionally change the maximum nesting level of your custom payload objects.
  7. fastcgi_param FULFILLMENT_MESSAGE_MAX_NESTING 64
  8. fastcgi_pass php;
  9. fastcgi_index DetectIntent.php;
  10. ...
  11. }

I have not tested this!! The php upstream config is up to you.