Phish.net API Wrappers

Phish.net API Wrappers: PHP

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($chCURLOPT_POST,true);
    if(
is_array($data)) { $data http_build_query($data); }
    
curl_setopt($chCURLOPT_POSTFIELDS,$data);
    
curl_setopt($chCURLOPT_FOLLOWLOCATION,1);
    
curl_setopt($chCURLOPT_HEADER,0);  // DO NOT RETURN HTTP HEADERS
    
curl_setopt($chCURLOPT_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

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

© 1990-2024  The Mockingbird Foundation, Inc. | Hosted by Linode