Integrate API To WordPress
-
Hello Support Team,
I want to integrated API into my wordpress site , please help me can u please tell me the steps i am new to the api integration , i have got this file from the provider its a logistic API
<?php //importamos la libreria nusoap require_once('lib/nusoap.php'); // Crear un cliente apuntando al script del servidor (Creado con WSDL) $serverURL = 'https://labelqa.estafeta.com/EstafetaLabel20/services'; $serverScript = 'EstafetaLabelWS'; $metodoALlamar = 'createLabel'; $cliente = new nusoap_client("$serverURL/$serverScript?wsdl", 'wsdl'); // Se pudo conectar? $error = $cliente->getError(); if ($error) { echo '<pre style="color: red">' . $error . '</pre>'; echo '<p style="color:red;' > htmlspecialchars($cliente->getDebug(), ENT_QUOTES) . '</p>'; die(); } //Información del envio $originInfo = array( 'address1' => 'Cumbres de maltrata 503 10', 'city' => 'Distrito Federal', 'contactName' => 'Manuel Mayorga', 'corporateName' => 'Develop inc', 'customerNumber' => '0000000', 'neighborhood' => 'Ni?os Heroes', 'state' => 'Distrito Federal', 'valid' => true, 'zipCode' => '03440' ); //Informació del destinatario $destinationInfo = array( 'address1' => 'Fco. Perez', 'city' => 'Escuinapa', 'contactName' => 'Juan Mayorga', 'corporateName' => 'Platios Juan', 'customerNumber' => '0000000', 'neighborhood' => 'Centro', 'state' => 'Sinaloa', 'valid' => true, 'zipCode' => '82457' ); //Información del envio $LabelDescription = array( 'content' => 'Este es el contenido', 'deliveryToEstafetaOffice' => true, 'numberOfLabels' => 1, 'parcelTypeId' => 1, 'false' => false, 'serviceTypeId' => '50', 'weight' => 10.45, 'originZipCodeForRouting' => '03440', 'destinationInfo' => $destinationInfo, 'originInfo' => $originInfo, 'returnDocument' => false, 'officeNum' => '130' ); $labelDescriptionList[0]=$LabelDescription; $labelDescriptionList[1]=$LabelDescription; //Colocamos datos de autentificación $parametros= array( 'valid' => true, 'password' => 'lAbeL_K_11', 'labelDescriptionCount' => 1, 'login' => 'prueba1', 'customerNumber' => '0000000', 'labelDescriptionList' => $labelDescriptionList, 'suscriberId' => '28', 'paperType' => 1, 'quadrant' => 1 ); // 1. Llamar a la funcion getRespuesta del servidor $result = $cliente->call( "$metodoALlamar", // Función a llamar array('in0'=>$parametros), // Parametros pasados a la función "uri:$serverURL/$serverScript", // namespace "uri:$serverURL/$serverScript/$metodoALlamar" // SOAPAction ); // Verificar que los parámetros están correctos, y si lo estan mostrar. if ($cliente->fault) { echo '<b>Error: '; print_r($result); echo '</b>'; } else { $error = $cliente->getError(); if ($error) { echo '<b style="color: red">Error: ' . $error . '</b>'; } else if($result){ if ($result['globalResult']['resultCode'] != 0) { echo '<br><b>Respuesta de servidor: </b></br>' .$result['globalResult']['resultDescription']; exit; } //Creamos el archivo $archivo = 'c:\\test_'.date("YmdHis") . '.pdf'; $fp = fopen($archivo, "a"); $buffer = $result['labelPDF']; $write = fputs($fp, $buffer); fclose($fp); if ($write == false) { echo "No se ha podido crear el archivo."; exit; } echo '<br><b>El archivo se creó correctamente:</b></br>'.$archivo; } } ?>
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Integrate API To WordPress’ is closed to new replies.