Skip to content

Instantly share code, notes, and snippets.

@Tilotiti
Last active April 11, 2018 08:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tilotiti/7d3516d9c2e956b7b0ee5db0cc5c780b to your computer and use it in GitHub Desktop.
Save Tilotiti/7d3516d9c2e956b7b0ee5db0cc5c780b to your computer and use it in GitHub Desktop.
Bing SpellCheck PHP Exemple
<?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