Skip to content

Instantly share code, notes, and snippets.

@nathanhornby
Created November 21, 2014 15:22
Show Gist options
  • Save nathanhornby/e7cd757731894c926fee to your computer and use it in GitHub Desktop.
Save nathanhornby/e7cd757731894c926fee to your computer and use it in GitHub Desktop.
<?php
class extension_custom_api extends Extension {
public function about() {
return array(
'name' => 'Custom API',
'version' => '1.0',
'release-date' => '2012-22-08',
'author' => array(
'name' => '3Degrees Agency',
'website' => 'http://www.3degreesagency.com/',
'email' => '[email protected]'
)
);
}
public function getSubscribedDelegates(){
return array(
array(
'page' => '/frontend/',
'delegate' => 'DataSourcePreExecute',
'callback' => 'registerCustomFunctions'
),
array(
'page' => '/frontend/',
'delegate' => 'APICustomAction',
'callback' => 'APICustomAction'
)
);
}
public function registerCustomFunctions(){
Frontend::instance()->Page()->registerPHPFunction('CustomAPIGet');
}
public function APICustomAction($something){
normalFunction($something);
}
}
/* API GET
============================ */
function CustomAPIGet($type,$user){
$service_url = 'stuff'.'Subscriber/'.'stuff'.'/'.$type;
$curl = curl_init($service_url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Authorization: ' . buildKey() ));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$curl_response = curl_exec($curl);
curl_close($curl);
$curl_decoded = json_decode($curl_response, true);
return $curl_decoded;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment