levelman Posted April 19, 2013 Share Posted April 19, 2013 (edited) API REWQEST <?php /* * ** WHMCS JSON API Sample Code *** */ $url = "http://bp.craftgamer.ru/includes/api.php"; # URL to WHMCS API file goes here $username = "******"; # Admin username goes here $password = "******"; # Admin password goes here $postfields = array(); $postfields["username"] = $username; $postfields["password"] = md5($password); $postfields["action"] = "addclient"; $postfields["firstname"] = "Test"; $postfields["lastname"] = "User"; $postfields["companyname"] = "WHMCS"; $postfields["email"] = "demo@whmcs.com"; $postfields["address1"] = "123 Demo Street"; $postfields["city"] = "Demo"; $postfields["state"] = "Florida"; $postfields["postcode"] = "AB123"; $postfields["country"] = "US"; $postfields["phonenumber"] = "123456789"; $postfields["password2"] = "demo"; $postfields["currency"] = "1"; $postfields["responsetype"] = "json"; $query_string = ""; foreach ($postfields AS $k => $v) $query_string .= "$k=" . urlencode($v) . "&"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); $jsondata = curl_exec($ch); if (curl_error($ch)) die("Connection Error: " . curl_errno($ch) . ' - ' . curl_error($ch)); curl_close($ch); $arr = json_decode($jsondata); # Decode JSON String print_r($arr); # Output XML Response as Array echo "<textarea rows=50 cols=100>Request: ".print_r($postfields,true); echo "\nResponse: ".htmlentities($jsondata)."\n\nArray: ".print_r($arr,true); echo "</textarea>"; ?> Request: Array ( [username] => AdminApi [password] => 5fe03afff2a1d66efa255610fa79fb47 [action] => addclient [firstname] => Test [lastname] => User [companyname] => WHMCS => demo@whmcs.com [address1] => 123 Demo Street [city] => Demo [state] => Florida [postcode] => AB123 [country] => US [phonenumber] => 123456789 [password2] => demo [customfields] => YToxOntpOjE7czo2OiJHb29nbGUiO30= [currency] => 1 [responsetype] => json ) Response: {"result":"error","message":"1 Invalid Select Option<\/li>"} Array: stdClass Object ( [result] => error [message] => 1 Invalid Select Option</li> [result] => error [message] => 1 Invalid Select Option</li> - What is? All functions work but add client is not work Edited April 19, 2013 by levelman 0 Quote Link to comment Share on other sites More sharing options...
levelman Posted April 19, 2013 Author Share Posted April 19, 2013 phpinfo curl cURL support enabled cURL Information 7.22.0 Age 3 Features AsynchDNS No Debug No GSS-Negotiate Yes IDN Yes IPv6 Yes Largefile Yes NTLM Yes SPNEGO No SSL Yes SSPI No krb4 No libz Yes CharConv No Protocols dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, pop3, pop3s, rtmp, rtsp, smtp, smtps, telnet, tftp Host x86_64-pc-linux-gnu SSL Version OpenSSL/1.0.1 ZLib Version 1.2.3.4 0 Quote Link to comment Share on other sites More sharing options...
levelman Posted April 19, 2013 Author Share Posted April 19, 2013 curl cURL support enabled cURL Information 7.22.0 Age 3 Features AsynchDNS No Debug No GSS-Negotiate Yes IDN Yes IPv6 Yes Largefile Yes NTLM Yes SPNEGO No SSL Yes SSPI No krb4 No libz Yes CharConv No Protocols dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, pop3, pop3s, rtmp, rtsp, smtp, smtps, telnet, tftp Host x86_64-pc-linux-gnu SSL Version OpenSSL/1.0.1 ZLib Version 1.2.3.4 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.