Last active
April 11, 2018 08:51
-
-
Save Tilotiti/7d3516d9c2e956b7b0ee5db0cc5c780b to your computer and use it in GitHub Desktop.
Bing SpellCheck PHP Exemple
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
<?php | |
$host = 'https://api.cognitive.microsoft.com'; | |
$path = '/bing/v7.0/spellcheck?'; | |
$input = "Hollo, wrld!"; | |
$get = [ | |
'mkt' => 'en-US', | |
'mode' => 'proof' | |
]; | |
$post = [ | |
'text' => urlencode($input) | |
]; | |
// NOTE: Replace this example key with a valid subscription key. | |
$key = '{your key}'; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $host.$path.http_build_query($get)); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post)); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, [ | |
'Content-type: application/x-www-form-urlencoded', | |
'Ocp-Apim-Subscription-Key: '.$key | |
]); | |
$result = curl_exec($ch); | |
curl_close($ch); | |
$return = json_decode($result, true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment