Advertisement
Guest User

Untitled

a guest
Apr 10th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.14 KB | None | 0 0
  1. <?php
  2.  
  3.  $url = "http://wehost4you.dk/includes/api.php"; # URL to WHMCS API file
  4. $username = "username"; # Admin username goes here
  5. $password = "password"; # Admin password goes here
  6.  
  7.  $postfields["username"] = $username;
  8.  $postfields["password"] = md5($password);
  9.  $postfields["action"] = "addinvoicepayment"; #action performed by the [[API:Functions]]
  10. $postfields["invoiceid"] = "1";
  11.  $postfields["transid"] = "5555";
  12.  $postfields["gateway"] = "PayPal";
  13.  
  14.  $ch = curl_init();
  15.  curl_setopt($ch, CURLOPT_URL, $url);
  16.  curl_setopt($ch, CURLOPT_POST, 1);
  17.  curl_setopt($ch, CURLOPT_TIMEOUT, 100);
  18.  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  19.  curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
  20.  $data = curl_exec($ch);
  21.  $info  =   curl_getinfo( $ch );
  22.  curl_close($ch);
  23.  
  24.  $data = explode(";",$data);
  25.  
  26.  echo '<pre>'
  27.     . print_r( $data, 1 )
  28.     . print_r( $info, 1 );
  29.  
  30.  
  31.  foreach ($data AS $temp) {
  32.      $temp = explode("=",$temp);
  33.      $results[$temp[0]] = $temp[1];
  34.  }
  35.  
  36.  if ($results["result"]=="success") {
  37.      # Result was OK!
  38. } else {
  39.      # An error occured
  40.     echo "The following error occured: ".$results["message"];
  41.  }
  42.  
  43.  ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement