Am 10.09.2022 um 04:12 schrieb Timo:
>
> Hat jemand von Euch eine Idee oder einen Lösungsansatz, den ich
> verfolgen sollte?
>
Ein Lösungsansatz war php-curl zu Beginn, da ich damit bereits andere
API's abrufe, jedoch scheitere ich hier bei der Einbindung das
Zertifikats und dem Schlüssel für die Authentifizierung:
==========================================
$url =
'
https://kiteplatform-api.telefonica.com:8010/services/REST/GlobalM2M/Echo/v1/r12/echo';
$data = array(
"data" => "test"
);
$data_string = json_encode($data);
$ch=curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,
array(
'Content-Type:application/json',
'Content-Length: ' . strlen($data_string)
)
);
$result = curl_exec($ch);
curl_close($ch);
==========================================
Ein weiterer Ansatz war dann via SoapClient, wobei es allerdinst auch
nicht wirklich funktioniert hat.
==========================================
$api_url =
"
https://kiteplatform-api.telefonica.com:8010/services/REST/GlobalM2M/Echo/v1/r12/echo";
$stream_context_opts = array(
'http'=>array(
'method'=>"POST /services/REST/GlobalM2M/Echo/v1/r12/echo",
'header'=> "Content-Type: application/soap+xml; charset=utf-8\r\n",
'data' => "test\r\n"
)
);
$soap_stream_context = stream_context_create($stream_context_opts);
$soap_options = array(
'cache_wsdl' => WSDL_CACHE_NONE,
'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP,
'exceptions' => true,
'trace' => true,
'local_cert' => '/etc/certs/customer-USER.cer',
'soap_version' => 'SOAP_1_2',
stream_context' => $soap_stream_context,
'authentication' => SOAP_AUTHENTICATION_DIGEST
);
try {
$client = new SoapClient( $api_url, $options );
} catch (SoapFault $e) {
echo $e->getMessage();
}
==========================================
Gruß
Timo