The following wrapper function can communicate with the Phish.net API using cURL. Include this function in any page to establish a connection with phish.net.
<?php
$myapikey ='XXXXX';
function pnet_api_req($data) {
$ch = curl_init('https://api.phish.net/api.js');
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 = [
'method'=>'pnet.forum.thread.get',
'apikey'=>$myapikey,
'format'=>'json',
'api'=>'2.0'
];
$arr = @json_decode(pnet_api_req($data),true); //set to true for an array or false for an object
if(is_array($arr)) { print_r($arr); } else { echo '<p>Unable to fetch phish.net API</p>'; }
This should provide you the infrastructure to communicate with the phish.net API using any method, including the writeable methods.
Phish.net 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 | DMCA
The Mockingbird Foundation is a non-profit organization founded by Phish fans in 1996 to generate charitable proceeds from the Phish community.
And since we're entirely volunteer – with no office, salaries, or paid staff – administrative costs are less than 2% of revenues! So far, we've distributed over $2 million to support music education for children – hundreds of grants in all 50 states, with more on the way.