PHP API Protection? -
i have simple php api. used curl
client , $_post
accept requests @ server side. ..
client:
<?php $ch = curl_init(); curl_setopt($ch, curlopt_url, "http://www.example.com/api-server"); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_postfields, array('q' => 'world!')); curl_setopt($ch, curlopt_header, 0); curl_setopt($ch, curlopt_returntransfer , 1); $response = curl_exec($ch); curl_close($ch); echo json_decode($response); ?>
server:
<?php echo json_encode("hello, ".$_post["q"]); ?>
my questions here are:
- am still following standard api logic anyway?
- how "protect" api server access?
dont try & write api engine, these industry standard. @ soap or rest.
here of libraries out there heavy lifting:
soap server http://framework.zend.com/manual/2.0/en/modules/zend.soap.server.html
soap client http://framework.zend.com/manual/2.0/en/modules/zend.soap.client.html
rest server
rest client
then protect these use basic http protection, through oauth etc
Comments
Post a Comment