PHP Methods for Connecting to the PeopleVine API

Leverage these methods to connect to the PeopleVine API via PHP.


Add this file to your project and call the PeopleVine API with these easy methods.


<?php class pvAPI { public function __construct($auth){ // Define All Authentication Variables Here $this->auth = $auth; $this->params = (object) Array(); $this->apiURL = 'https://api.peoplevine.com/'; } public function apiCall($category, $method, $params) { $query = $this->buildQuery($params); $apiURL = $this->apiURL . $category . '.asmx/' . $method; $response = $this->curlRequest($apiURL, $query); // If no error - only return the data requested // If error - return the full response // return $this->auth; return $response->isError != true ? $response->returnObject : $response; } private function buildQuery($params){ $params['auth'] = $this->auth; return json_encode($params); } // Method To Make Soap Request private function curlRequest($apiURL, $query) { $ch = curl_init(); $headers = Array( 'Content-Type: application/json; charset=utf-8' ); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_URL, $apiURL); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $query); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = json_decode(curl_exec($ch)); curl_close($ch); return json_decode($result->d); } }

You can call it by using the following:


$pv = new pvAPI([ "api_username" => "xxxx", "api_password" => "xxxx", "api_key" => "xxxx", "username" => "xxxx", "password" => "xxxx", "company_no" => 0000 ]); $params = "answers" => [ [ "customer_no" => 0000, "survey_no" => 000, "survey_answer" => "", "survey_field_no" => 0000], [ "survey_field_no" => 0000, "survey_no" => 0000, "customer_no" => 0000, "survey_answer" => "" ], [ "survey_field_no" => 00000, "customer_no" => 0000, "survey_no" => 000, "survey_answer" => "" ] ]; $var = $pv->apiCall('survey', 'answerSurvey', $params);

Additional Help Tutorials

Find more ways to grow on PeopleVine.

Configure Salto to Work with Peoplevine Check-In

Follow these steps to configure your Salto to auto Check-In members when they use a Salto keycard.

Posted January 12, 2024

© Peoplevine 2025. Powered by PeopleVine. Terms of use | Privacy & cookies