kittenofd00m

str-apis.php

Nov 19th, 2023 (edited)
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.31 KB | Source Code | 0 0
  1. function callStreamlineAPI($methodName, $params) {
  2.  
  3.     #API Token
  4.    $token = '**************************';
  5.     #API Token_Secret
  6.    $token_secret = '********************************';
  7.     #API Endpoint
  8.    $endpoint = 'https://web.dataprovider.com/api/json';
  9.  
  10.     $body=array();
  11.  
  12.     $params['token_secret'] = $token_secret;
  13.     $params['token_key'] = $token;
  14.  
  15.     $body['methodName'] = $methodName;
  16.     $body['params'] = $params;
  17.     $body = json_encode($body, JSON_UNESCAPED_SLASHES);
  18.  
  19.     $curl = curl_init();
  20.  
  21.     curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
  22.     curl_setopt($curl, CURLOPT_POSTFIELDS, $body);
  23.     curl_setopt($curl, CURLOPT_POST, 1);
  24.     curl_setopt($curl, CURLOPT_URL, $endpoint);
  25.     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  26.  
  27.     $result = curl_exec($curl);
  28.  
  29.     if($result === false) {
  30.        
  31.         return 'Curl error: ' . curl_error($curl);
  32.        
  33.     } else {
  34.  
  35.         return $result;    
  36.  
  37.     }
  38.  
  39.     curl_close($curl);
  40.  
  41. }
  42.  
  43. function getPropertyList(){
  44.     $params = array();
  45.     $params['status_id'] = 1;
  46.  
  47.     $test = callStreamlineAPI('GetPropertyList', $params );
  48.    
  49.     print_r($test);
  50.  
  51.     $test = json_encode($test, JSON_PRETTY_PRINT);
  52.     echo "<script>console.log($test)</script>";
  53.     echo $test;
  54.  
  55. }
Tags: api php wordpress
Advertisement
Add Comment
Please, Sign In to add comment