Jump to content

add client api


Recommended Posts

Good afternoon, I have doubts on how to add a client from the api, where this is my code, thanks in advance.

 

$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$companyname=$_POST['companyname'];
$email=$_POST['email'];
$address1=$_POST['address1'];
$address2=$_POST['address2'];
$city=$_POST['city'];
$state=$_POST['state'];
$postcode=$_POST['postcode'];
$country=$_POST['country'];
$phonenumber=$_POST['phonenumber'];
$id=$_POST['id'];
$password2=$_POST['password'];
$credit=$_POST['credit'];
$taxexempt=$_POST['taxexempt'];
$latefeeoveride=$_POST['latefeeoveride'];
$overideduenotices=$_POST['overideduenotices'];
$datecreated=$_POST['datecreated'];
$notes=$_POST['notes'];
$billingcid=$_POST['billingcid'];
$securityqid=$_POST['securityqid'];
$securityqans=$_POST['securityqans'];
$groupid=$_POST['groupid'];
$cardtype=$_POST['cardtype'];
$cardlastfour=$_POST['cardlastfour'];
$cardnum=$_POST['cardnum'];
$startdate=$_POST['startdate'];
$expdate=$_POST['expdate'];
$issuenumber=$_POST['issuenumber'];
$gatewayid=$_POST['gatewayid'];
$lastlogin=$_POST['lastlogin'];
$ip=$_POST['ip'];
$host=$_POST['host'];
$statusstatus=$_POST['statusstatus'];
$language=$_POST['language'];
$pwresetkey=$_POST['pwresetkey'];
$pwresetexpiry=$_POST['pwresetexpiry'];


$selectdata=mysql_query("select email from tblclients where email='".$email."';");

if($viewdata=mysql_fetch_array($selectdata))
{
?>
<table>
	<tr bgcolor="#FF9999">
		<td>
   		<font color="#CC0000">Lo sentimos los datos no se han insertado satisfactoriamente puede ser debido a que ya existen en la base de datos. Por favor intentelo nuevamente y verifique. <a href="index.php">[Home]</a></font>
	    </td>
	</tr>
	</table>
<?
}
else
{
$url = "http://www.yupifon.com/dev/xerp/includes/api.php"; # URL to WHMCS API file
$username = "admin"; # Admin username goes here
$password = "P89123fD8"; # Admin password goes here

$postfields["username"] = $username;
$postfields["password"] = md5($password);

$postfields["action"] = "addclient"; 
$postfields["firstname"] = $firstname;
$postfields["lastname"] = $lastname;
$postfields["companyname"] = $companyname;
$postfields["email"] = $email;
$postfields["address1"] = $address1;
$postfields["address2"] = $address2;
$postfields["city"] = $city;
$postfields["state"] = $state;
$postfields["postcode"] = $postcode;
$postfields["country"] = $country;
$postfields["phonenumber"] = $phonenumber;
$postfields["password2"] = $password2;
$postfields["currency"]= "1";
$postfields["groupid"] = $groupid;
$postfields["notes"]=$notes;
$postfields["cctype"]=$cardtype;
$postfields["cardnum"]=$cardnum;
$postfields["expdate"]=$expdate;
$postfields["startdate"]=$startdate;
$postfields["issuenumber"]=$issuenumber;

$postfields["customfields"]="prueba";
$postfields["noemail"]=true;

$postfields["credit"]=$credit;
$postfields["taxexempt"]=$taxexempt;
$postfields["latefeeoveride"]=$latefeeoveride;
$postfields["overideduenotices"]=$overideduenotices;
$postfields["datecreated"]=$datecreated;
$postfields["billingcid"]=$billingcid;
$postfields["securityqid"]=$securityqid;
$postfields["securityqans"]=$securityqans;
$postfields["cardlastfour"]=$cardlastfour;
$postfields["gatewayid"]=$gatewayid;
$postfields["lastlogin"]=$lastlogin;
$postfields["ip"]=$ip;
$postfields["host"]=$host;
$postfields["statusstatus"]=$statusstatus;
$postfields["language"]=$language;
$postfields["pwresetkey"]=$pwresetkey;
$postfields["pwresetexpiry"]=$pwresetexpiry;


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);

	if(($data = curl_exec($ch)) === false)
	{
		echo 'Curl error: ' . curl_error($ch);
	}
	else

	curl_close($ch);

$data = explode(";",$data);
foreach ($data AS $temp) {
  $temp = explode("=",$temp);
  $results[$temp[0]] = $temp[1];
}

if ($results["result"]=="success") {
  header("Location: dataclients.php?correct=1 && id=".$id." ");
} 
else {
	?>
	<table>
	<tr bgcolor="#FF9999">
		<td>
   		<font color="#CC0000">Lo sentimos los datos no se han insertado satisfactoriamente. Por favor intentelo nuevamente. <a href="index.php">[Home]</a></font>
           <br />
           <br />
           <?
		echo "The following error occured: ".$results["message"];
		?>
	    </td>
	</tr>
	</table>
	<?php
	}
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated