API Wrappers: PHP

The following wrapper function can communicate with the API using cURL. Include this function in any page to establish a connection with
<?php $myapikey ='XXXXX'; function pnet_api_req($data, $method=false) { if(!$method && isset($data['method'])) { // you can pass the method as an element of the data array // or you can use it as an argument in the function $method= "/".str_replace(".","/",$data['method']); } $ch = curl_init(''.$method); curl_setopt($ch, CURLOPT_POST,true); if(is_array($data)) { $data = http_build_query($data); } curl_setopt($ch, CURLOPT_POSTFIELDS,$data); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); curl_setopt($ch, CURLOPT_HEADER,0); // DO NOT RETURN HTTP HEADERS curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // RETURN THE CONTENTS OF THE CALL return curl_exec($ch); }

The next step is to send data to the function. Here is an example method call:
<?php $data = [ 'apikey'=>$myapikey, 'method'=>'setlists.latest' ]; $arr = @json_decode(pnet_api_req($data),true); //set to true for an array or false for an object if(is_array($arr)) { var_dump($arr); } else { error_log('Unable to fetch API :('; }

This should provide you the infrastructure to communicate with the API using any method, including the writeable methods. is a non-commercial project run by Phish fans and for Phish fans under the auspices of the all-volunteer, non-profit Mockingbird Foundation.

This project serves to compile, preserve, and protect encyclopedic information about Phish and their music.

Credits | Terms Of Use | Legal

© 1990-2019  The Mockingbird Foundation, Inc. | Hosted by End Point Corporation