Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Пример работы с подсказками DaData на PHP (через cUrl)
class Dadata
public function suggest($type, $fields)
$result = false;
if ($ch = curl_init("$type"))
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Token ВАШ_API_КЛЮЧ'
curl_setopt($ch, CURLOPT_POST, 1);
// json_encode
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
$result = json_decode($result, true);
return $result;
$result = Dadata::suggest("address", array("query"=>"Москва", "count"=>2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment