-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
François MATHIEU
committed
Mar 20, 2018
1 parent
1684fe7
commit 70faf14
Showing
8 changed files
with
81 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
parameters: | ||
gos_web_host: '%env(GOS_WEB_HOST)%' | ||
gos_web_port: '%env(GOS_WEB_PORT)%' | ||
luis_url: '%env(LUIS_URL)%' | ||
luis_key: '%env(LUIS_KEY)%' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace App\Utils; | ||
|
||
/** | ||
* Class LuisSDK | ||
* | ||
* @author François MATHIEU <[email protected]> | ||
*/ | ||
class LuisSDK | ||
{ | ||
|
||
/** @var string url */ | ||
private $url; | ||
|
||
/** | ||
* LuisSDK constructor. | ||
* @param $luisUrl | ||
* @param $luisKey | ||
*/ | ||
public function __construct($luisUrl, $luisKey) | ||
{ | ||
$this->url = sprintf("%s?subscription-key=%s&verbose=true&timezoneOffset=0&q=", $luisUrl, $luisKey); | ||
} | ||
|
||
/** | ||
* Send a GET Request and return its result | ||
* | ||
* @param string $text | ||
* @return array | ||
*/ | ||
public function query($text) | ||
{ | ||
$url = $this->url . $text; | ||
$url = str_replace(' ', '%20', $url); | ||
$ch = curl_init(); | ||
curl_setopt($ch, CURLOPT_URL, $url); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
curl_setopt($ch, CURLOPT_MAXREDIRS, 10); | ||
curl_setopt($ch, CURLOPT_TIMEOUT, 30); | ||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); | ||
|
||
$data = curl_exec($ch); | ||
curl_close($ch); | ||
|
||
return json_decode($data, true); | ||
} | ||
} |