我正在尝试在我的代码中进行同步api调用,并且本机不允许这样做。我尝试异步使用fetch,但我收到'网络请求失败'错误。这是我想要转换的代码:
var adfsUrl = null;
try {
let response = await fetch(url + '/XrmServices/2011/Organization.svc?wsdl=wsdl0',
{
method: 'GET',
headers: {
'Connection': 'Keep-Alive',
'Accept': 'application/json',
'Content-Type': 'application/soap+xml; charset=UTF-8',
},
});
let responseJson = await response.json();
adfsUrl = $(responseJson).find('ms-xrm\\:Identifier');
return $(adfsUrl[0]).text().replace("http://", "https://");
} catch(error) {
console.error(error);
}
我失败的尝试代码:
/**
* Flatten a multi-dimensional associative array with dots.
*
* @param array $array
* @param string $prepend
* @return array
*/
public static function dot($array, $prepend = '')
{
$results = [];
foreach ($array as $key => $value) {
if (is_array($value) && ! empty($value)) {
$results = array_merge($results, static::dot($value, $prepend.$key.'.'));
} else {
$results[$prepend.$key] = $value;
}
}
return $results;
}