Here's my current code:
$header = [
'phoneType' => $mobileType
];
\Drupal::logger("cam")->debug('PageNameHere retrieveAPINameHere REQUEST: '.json_encode($header));
$filterPhone = MAPClient2::req( 'get', $context, $header, NULL);
Now, I need to make two request now with a new API with the following request:
{
"configuration": "techDescriptions",
"automated":"<phon>",
"lalaBox":true
}
{
"configuration": "techDescriptions",
"automationBu":"<phoneType>",
"lalaBox":false
}
Is this the right way to do it?
$header = [
"configuration": "techDescriptions",
"automationBu":"<phoneType>",
"lalaBox":false
];
$header = [
"configuration": "techDescriptions",
"automationBu":"<phoneType>",
"lalaBox":treu
];
\Drupal::logger("cam")->debug('PageNameHere retrieveNEWAPINameHere REQUEST: '.json_encode($header));
$filterPhone = MAPClient2::req( 'get', $context, $header, NULL);
When doing this you overwrite the $header variable. You should maybe have another name that makes more sense for the second header you need to send. I'll put $header2 so you understand but you should find a better name
$header = [
"configuration": "techDescriptions",
"automationBu":"<phoneType>",
"lalaBox":false
];
$header2 = [
"configuration": "techDescriptions",
"automationBu":"<phoneType>",
"lalaBox":treu
];
\Drupal::logger("cam")->debug('PageNameHere retrieveNEWAPINameHere REQUEST: '.json_encode($header));
$filterPhone = MAPClient2::req( 'get', $context, $header, NULL);
\Drupal::logger("cam")->debug('PageNameHere retrieveNEWAPINameHere REQUEST: '.json_encode($header));
$filterPhone = MAPClient2::req( 'get', $context, $header2, NULL);
$header = [
"configuration": "techDescriptions",
"automationBu":"<phoneType>",
"lalaBox":false
];
\Drupal::logger("cam")->debug('PageNameHere retrieveNEWAPINameHere REQUEST: '.json_encode($header));
$filterPhone1 = MAPClient2::req( 'get', $context, $header, NULL);
$header = [
"configuration": "techDescriptions",
"automationBu":"<phoneType>",
"lalaBox":treu
];
\Drupal::logger("cam")->debug('PageNameHere retrieveNEWAPINameHere REQUEST: '.json_encode($header));
$filterPhone2 = MAPClient2::req( 'get', $context, $header, NULL);
Just do 2 requests. In your example, you only overwrite the header variable. And I think the in the second header you mean true not treu?
You could also put the 2 headers together in one array and later call them twice as :
\Drupal::logger("cam")->debug('PageNameHere retrieveNEWAPINameHere REQUEST: '.json_encode($header));
$filterPhone = MAPClient2::req( 'get', $context, $header[0], NULL);
\Drupal::logger("cam")->debug('PageNameHere retrieveNEWAPINameHere REQUEST: '.json_encode($header));
$filterPhone = MAPClient2::req( 'get', $context, $header[1], NULL);
But you don't win much though, but might be more convenient later when you want to add more headers.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.