Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. //<-- Giovani de Alencar - Show 2019 -->//
  4. function cUrlGetData($url) {
  5. $post_fields = '';
  6. $ch = curl_init();
  7. $timeout = 5;
  8. curl_setopt($ch, CURLOPT_URL, 'https://gestor.showtecnologia.com/rest_20190719_2/index.php/api/'.$url.'');
  9. if ($post_fields && !empty($post_fields)) {
  10. curl_setopt($ch, CURLOPT_POST, 1);
  11. curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
  12. }
  13.  
  14. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers = array(
  15. 'Content-Type: application/x-www-form-urlencoded',
  16. 'SHOW-API-KEY: go00840cooswgwk8o4c0kwgws000okkk848kscko', //Auth token WebService
  17. 'charset: utf-8',
  18. ));
  19. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  20. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  21. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  22. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  23. $data = curl_exec($ch);
  24. if (curl_errno($ch)) {
  25. echo 'Error:' . curl_error($ch);
  26. }
  27. curl_close($ch);
  28. if($data){
  29. $retorno = json_decode($data, true);
  30. return $retorno;
  31. }else{
  32. return false;
  33. }
  34. }
  35. //<!-- Giovani de Alencar - Show 2019 -->//
  36.  
  37.  
  38.  
  39. COMO USAR:
  40. //CHAMA A INTEGRAÇÃO
  41. $this->load->helper('integracao_ws');
  42.  
  43. //CONFIGURACAO DA INTEGRACAO
  44. $serial = "";
  45. $comando = "";
  46. $url = "send_command?serial=$serial&command=$comando"; //URL POST REQUEST
  47. $dataCURL = cUrlGetData($url);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement