Posted By

davidinv on 09/05/09


Tagged

control structures api


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

ncho
umang_nine


getApi


 / Published in: PHP
 

获取API

  1. function getApi($data, $url='http://opentags.org/api/'){
  2. $curl = curl_init();
  3. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
  4. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  5. curl_setopt($curl, CURLOPT_HEADER, 0);
  6. curl_setopt($curl, CURLOPT_POST, 1);
  7. curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
  8. curl_setopt($curl, CURLOPT_URL, $url);
  9. if(false === ($msg = curl_exec($curl))){
  10. //echo 'Error: '.curl_error($curl);
  11. return false;
  12. }else{
  13. curl_close($curl);
  14. return json_decode($msg);
  15. }
  16. }

Report this snippet  

You need to login to post a comment.