Title: Integrate API To WordPress
Last modified: August 30, 2016

---

# Integrate API To WordPress

 *  [mis.vivek](https://wordpress.org/support/users/misvivek/)
 * (@misvivek)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/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)

 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [10 years, 8 months ago](https://wordpress.org/support/topic/integrate-api-to-wordpress/#post-6563408)
 * Which theme are you working with?
 *  Thread Starter [mis.vivek](https://wordpress.org/support/users/misvivek/)
 * (@misvivek)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/integrate-api-to-wordpress/#post-6563410)
 * Betheme
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [10 years, 8 months ago](https://wordpress.org/support/topic/integrate-api-to-wordpress/#post-6563413)
 * I couldn’t find that theme: [https://wordpress.org/themes/search/betheme/](https://wordpress.org/themes/search/betheme/)–
   If it’s a commercial theme then you’re best talking to your theme’s vendors/ 
   authors about how to integrate this code in.
 *  Thread Starter [mis.vivek](https://wordpress.org/support/users/misvivek/)
 * (@misvivek)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/integrate-api-to-wordpress/#post-6563429)
 * [http://themeforest.net/item/betheme-responsive-multipurpose-wordpress-theme/7758048](http://themeforest.net/item/betheme-responsive-multipurpose-wordpress-theme/7758048)
 * its a theme
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [10 years, 8 months ago](https://wordpress.org/support/topic/integrate-api-to-wordpress/#post-6563430)
 * The author can be found here: [http://themeforest.net/user/muffingroup](http://themeforest.net/user/muffingroup)
 *  Thread Starter [mis.vivek](https://wordpress.org/support/users/misvivek/)
 * (@misvivek)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/integrate-api-to-wordpress/#post-6563598)
 * Hello Andrew,
    i have purchased theme from [http://themeforest.net/item/betheme-responsive-multipurpose-wordpress-theme/7758048](http://themeforest.net/item/betheme-responsive-multipurpose-wordpress-theme/7758048)
 * i just want to integrate API in this, can you please help me to know how to integrate
   API to wordpress, i have a code but dont know where to add and get the result.
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [10 years, 8 months ago](https://wordpress.org/support/topic/integrate-api-to-wordpress/#post-6563601)
 * That would require me to spend money to help you – why not just ask the person
   who made theme?

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Integrate API To WordPress’ is closed to new replies.

## Tags

 * [api](https://wordpress.org/support/topic-tag/api/)
 * [api-integration](https://wordpress.org/support/topic-tag/api-integration/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 2 participants
 * Last reply from: [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * Last activity: [10 years, 8 months ago](https://wordpress.org/support/topic/integrate-api-to-wordpress/#post-6563601)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
