/** * Sends a post request to the provided url * * @param $url * @param array $postData * @param array $getData * * @return mixed * @throws \Domynation\Exceptions\ApiException */ public function post($url, $postData = [], $getData = []) { $getData = $this->encode($getData); $postData = $this->encode($postData); $response = $this->client->post($url, ['query' => $this->prepareQuery($getData), 'body' => $postData]); $json = $response->json(); if (array_key_exists('error', $json)) { throw new ApiException($json['error']['message'], $json['error']['code']); } return utf8_decode_array($json); }
/** * Decodes UTF8 recursivly for the given array * * @deprecated */ function utf8_decode_array(&$array) { trigger_error('deprecated utf8_decode_array called', E_USER_WARNING); foreach (array_keys($array) as $key) { if ($key === 'dn') { continue; } if ($key === 'jpegPhoto') { continue; } if (is_array($array[$key])) { utf8_decode_array($array[$key]); } else { $array[$key] = utf8_decode($array[$key]); } } }
function utf8_decode_array ( $array ) { $retour = array(); if ( !empty($array) ) { foreach ( $array as $key => $value ) { if ( is_array($value) ) { $retour[$key] = utf8_decode_array($value); } else { $retour[$key] = utf8_decode($value); } } } unset($array); return $retour; }
/** * Converts each elements of an array to UTF-8. * * @param array $array * * @return array */ function utf8_decode_array(array $array) { $decoded = []; foreach ($array as $key => $value) { $decoded[$key] = is_array($value) ? utf8_decode_array($value) : utf8_decode($value); } return $decoded; }