Forum

Thread tagged as: Question, Api, Add-on-development

Accessing API setting outside of the Admin

Is it possible to access a API setting outside of the admin?

I need to pull in a license key into a page that is in the root from a setting that the user puts in the admin settings area. Is that possible to do?

Thanks in advance.

Brandon

Brandon Livengood

Brandon Livengood 1 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, in pretty much the same way.

$API  = new PerchAPI(1.0, 'my_sample');
$Settings = $API->get('Settings');
echo $Settings->get('my_setting')->val();

Yeah I did that but I was getting this error.

Fatal error: Class 'PerchAPI' not found in /home/bytescom/public_html/checkout/charge.php on line 3
Drew McLellan

Drew McLellan 2638 points
Perch Support

Have you included the Perch runtime in that page?

Doh - I didn't. I put it in there and it works now.

I also have a session_start() should runtime go before or after that just for order purposes?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Before would be best.

Okay you got it. Thanks