DavidWn Posted January 10, 2013 Share Posted January 10, 2013 So I'm writing an api that my clients can use in their sites. I don't want to give them direct access to the code. I have the script on api.XXXXXX.com index.php contains: <?php require_once('base.php'); require_once('client.php'); class api extends client { function __construct($config = null) { return parent::__construct($config); } } //....Other Code ?> Is it possible for my clients to access the API class by including it in their site? For example: <?php require_once('http://api.XXXXXX.com/index.php'); class service{ private $client; function __construct() { $this->client = new api(); } } //....Other Code ?> Quote Link to comment https://forums.phpfreaks.com/topic/272930-cross-domain-script-access/ Share on other sites More sharing options...
cpd Posted January 10, 2013 Share Posted January 10, 2013 Including via http doesn't work the same as a local include. The script your requesting through http will still be executed on the server it resides and any output included in your script. I.e. if someone includes your script you would have to print your class out for them to use it and even then it wouldn't work because you have dependencies they can't get their hands on for the same reason. Quote Link to comment https://forums.phpfreaks.com/topic/272930-cross-domain-script-access/#findComment-1404625 Share on other sites More sharing options...
Muddy_Funster Posted January 10, 2013 Share Posted January 10, 2013 So I'm writing an api that my clients can use in their sites. I don't want to give them direct access to the code. I'm not really getting the logic behind that statement. Quote Link to comment https://forums.phpfreaks.com/topic/272930-cross-domain-script-access/#findComment-1404643 Share on other sites More sharing options...
Ninjakreborn Posted January 10, 2013 Share Posted January 10, 2013 Creating an API can be easy, or hard depending on the type of API. Your best bet would be to get familiar with different types of API's and various web services, and find out which approach would be best for your needs. The tutorials located here: http://www.webresourcesdepot.com/how-to-create-an-api-10-tutorials/ Will get you up and running in regards to building API's within just a couple of hours. Go through the first couple of tutorials, and all your questions will be answered and you'll have a good idea of how you want to put your API together. Quote Link to comment https://forums.phpfreaks.com/topic/272930-cross-domain-script-access/#findComment-1404700 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.