fcastillo@xpress.com.mx Posted October 28, 2010 Share Posted October 28, 2010 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 } } 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.