Developer API Documentation


TicksyAPI Class

Here’s a handy PHP Class to use for all Ticksy API endpoints (GET and POST). We will be using this as the example class throughout this documentation.

// Ticksy PHP Class
class TicksyAPI {

   // Curl Post
   public function ticksy_api_post($url,$post_vars = false,$user_agent = false){
 
      // Open Connection
      $ch = curl_init();
 
      curl_setopt($ch,CURLOPT_POST,false); 
      curl_setopt($ch,CURLOPT_URL, $url);
      curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
      curl_setopt($ch,CURLOPT_USERAGENT,$user_agent);
 
      // Is this a POST?
      if (!empty($post_vars)):
 
         $post_string = http_build_query($post_vars);
         curl_setopt($ch,CURLOPT_POST, count($post_vars));
         curl_setopt($ch,CURLOPT_POSTFIELDS, $post_string);
 
      endif;
 
      // Execute Post
      $result = curl_exec($ch);
      $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
      // Close Connection
      curl_close($ch);
 
      return $result;

   }

}