Finished the API User Creator .....

opzero

Verified User
Joined
May 3, 2008
Messages
9
[NOT SOLVED] Finished the API User Creator .....

unfortunnately..
some error appear

The Error was ERROR PASSWORD INCORRECT

please help me

PHP:
<?php

if($_GET['create'] == 1)
{ 
if($_POST['pass'] != "pass"){echo "ERROR PASSWORD INCORRECT";exit;}

include 'httpsocket.php';

$create = new HTTPSocket;
$create->connect('https://:>.com',2222);

$create->set_login("", "");

$create->set_method('POST');

$create->query('/CMD_API_ACCOUNT_USER',
	array(
        'username' => $_POST['username'], // The User's username. 4-8 characters, alphanumeric 
        'email' => $_POST['email'], // A valid email address 
        'passwd' => $_POST['pwd'], // The User's password. 5+ characters, ascii 
        'passwd2' => $_POST['pwd2'], // Password double check. 5+ characters, ascii 
        'domain' => $_POST['domain'], // A valid domain name in the form: domain.com 
        'package' => $_POST['package'], // One of the User packages created by the Reseller 
        'ip' => '202.XXX.178.182', // One of the ips which is available for user creation. Only free or shared ips are allowed. 
        'notify' => 'yes', // yes or no. If yes, an email will be sent to email 
        'action' => 'create', 
        'add' => 'Submit' 
    ));

$result = $create->fetch_parsed_body(); 

if($result['error'] == 1)
{ 
?>
<center>Error Creating account<br>The Error Is : <? echo "$result[details]"; ?> </center>
<?php
}
else
{
?>
<center>Account Successfuly Created. An Email has been sent with more information.<br></center>
<?php
} 

exit;
}

?>

<html>
<form action='<?=$PHP_SELF;?>?create=1' method='post' name='form'>
<div align="center">
  <table width="600" border="0" cellpadding="0" cellspacing="0" bordercolor="#333333">
    <tr>
      <td width="300"><div align="center">Username*:</div></td>
      <td width="300">
        <div align="justify">
          <input name='username' type='text' style="WIDTH: 300px" />
        </div></td>
    </tr>
    <tr>
      <td><div align="center">Email:</div></td>
      <td>
        <div align="justify">
          <input name='email' type='text' style="WIDTH: 300px" />
        </div></td>
    </tr>
    <tr>
      <td><div align="center">Password**:</div></td>
      <td>
        <div align="justify">
          <input name='pwd' type='password' style="WIDTH: 300px" />
        </div></td>
    </tr>
    <tr>
      <td><div align="center">Password Validate**:</div></td>
      <td>
        <div align="justify">
          <input name='pwd2' type='password' style="WIDTH: 300px" />
        </div></td>
    </tr>
    <tr>
      <td><div align="center">Domain:</div></td>
      <td>
        <div align="justify">
          <input type="text" name='domain' style="WIDTH: 300px" />
        </div></td>
    </tr>
    <tr>
      <td><div align="center">Bandwidth:</div></td>
      <td> <div align="center">10 GB + </div></td>
    </tr>
    <tr>
      <td bordercolor="#666666"><div align="center">U - Bandwidth:</div></td>
      <td bordercolor="#666666"><div align="center">
          <input type="radio" value='on' name='package' checked="checked" />
        PL1000
        <input type="radio" value='off' name='package' />
        PL500 </div></td>
    </tr>
    <tr>
      <td colspan="2" bordercolor="#666666"><div align="center">
          <input name="submit" type="submit" value='Submit' />
          <br />
        * 4-8 Characters, alphanumeric<br />
        ** 5+ Characters, alphanumeric<br />
        Cheaked means yes</div></td>
    </tr>
  </table>
</div>
<div align="center"></div>
</form>
</html>
 
Last edited:
Well don't leave us in suspense. What is the error?

EDIT: I like how you edited your first post as if you had posted the error from the start.
 
the error was

ERROR PASSWORD INCORRECT

but i am sure the password is correct
 
Code:
if($_POST['pass'] != "pass"){echo "ERROR PASSWORD INCORRECT";exit;}

This line says that if the password you entered into the form field doesn't equal the word "pass" then print the error and exit. Is "pass" the password you are entering? If not then the script will print the error and exit.
 
edited

but seems cannot run ........

PHP:
<?php 

include 'httpsocket.php'; 

$sock = new HTTPSocket; 
$sock->connect('ssl://202.181.1XX.182',2222); 

$sock->set_login("2","2"); 

$sock->set_method('POST'); 

$sock->query('/CMD_API_ACCOUNT_USER', 
	array(
        'username' => $_POST['username'], // The User's username. 4-8 characters, alphanumeric 
        'email' => $_POST['email'], // A valid email address 
        'passwd' => $_POST['pwd'], // The User's password. 5+ characters, ascii 
        'passwd2' => $_POST['pwd2'], // Password double check. 5+ characters, ascii 
        'domain' => $_POST['domain'], // A valid domain name in the form: domain.com 
        'package' => $_POST['package'], // One of the User packages created by the Reseller 
        'ip' => '202.181.178.182', // One of the ips which is available for user creation. Only free or shared ips are allowed. 
        'notify' => 'yes', // yes or no. If yes, an email will be sent to email 
        'action' => 'create', 
        'add' => 'Submit' 
    ));

$result = $sock->fetch_body(); 

echo $result; 

?> 

<form method='post' name='form'>
<div align="center">
  <table width="600" border="0" cellpadding="0" cellspacing="0" bordercolor="#333333">
    <tr>
      <td width="300"><div align="center">Username* :</div></td>
      <td width="300">
        <div align="justify">
          <input name='username' type='text' style="WIDTH: 300px" />
        </div></td>
    </tr>
    <tr>
      <td><div align="center">Email :</div></td>
      <td>
        <div align="justify">
          <input name='email' type='text' style="WIDTH: 300px" />
        </div></td>
    </tr>
    <tr>
      <td><div align="center">Password** :</div></td>
      <td>
        <div align="justify">
          <input name='pwd' type='password' style="WIDTH: 300px" />
        </div></td>
    </tr>
    <tr>
      <td><div align="center">Password Validate** :</div></td>
      <td>
        <div align="justify">
          <input name='pwd2' type='password' style="WIDTH: 300px" />
        </div></td>
    </tr>
    <tr>
      <td><div align="center">Domain :</div></td>
      <td>
        <div align="justify">
          <input type="text" name='domain' style="WIDTH: 300px" />
        </div></td>
    </tr>
    <tr>
      <td><div align="center">Bandwidth :</div></td>
      <td> <div align="center">10 GB + </div></td>
    </tr>
    <tr>
      <td bordercolor="#666666"><div align="center">Package :</div></td>
      <td bordercolor="#666666"><div align="center">
          <input type="radio" value='on' name='package' checked="checked" />
        PL1000
        <input type="radio" value='off' name='package' />
        PL500 </div></td>
    </tr>
    <tr>
      <td colspan="2" bordercolor="#666666"><div align="center">
          <input name="submit" type="submit" value='Submit' />
          <br />
        * 4-8 Characters, alphanumeric<br />
        ** 5+ Characters, alphanumeric<br />
       </div></td>
    </tr>
  </table>
</div>
<div align="center"></div>
</form>
 
When I use the API I just put all the variables in a query string and post it.
 
It wasn't there when I checked it. Since opzero is not responding anymore I guess he got it fixed.
 
great to see ou online fl


i am tired to try any more

can you share your api script???:(

please
 
I use perl instead of php but its similar enough you can probably figure it out.

This creates a user with no domain.

Code:
use HTTP::Request::Common qw(GET);

$cmd = "CMD_API_ACCOUNT_USER?action=create\&package=$package\&add=Submit\&notify=no\&username=$in{'username'}\&email=$in{'email'}\&passwd=$in{'password'}\&passwd2=$in{'password'}\&ip=$ipaddress";

$url = "http://admin\:your_admin_password\@$ipaddress\:2222/$cmd";

my $req = GET $url;
 
.......

in fact...

i don know perl at all.......

can you convery it to php?

thanks
 
I use perl instead of php but its similar enough you can probably figure it out.

This creates a user with no domain.

Code:
use HTTP::Request::Common qw(GET);

$cmd = "CMD_API_ACCOUNT_USER?action=create\&package=$package\&add=Submit\&notify=no\&username=$in{'username'}\&email=$in{'email'}\&passwd=$in{'password'}\&passwd2=$in{'password'}\&ip=$ipaddress";

$url = "http://admin\:your_admin_password\@$ipaddress\:2222/$cmd";

my $req = GET $url;

I would love to get something like this working in Perl too, but I don't get it working :

Code:
--snip--
my $GET_CMD = "http://$dauser:$dapwd\@$daserver:$peerport$dacmd\n";
print "Debug GET_CMD : $GET_CMD";
my $sock = HTTP::Request->new(GET => $GET_CMD);
print "testing output\n";
print $sock;
print "\n";
print $out;
print "\n";
--snip--


results in :

Debug GET_CMD : http://xxxxxxx:********@www.mydomain.com:2222/CMD_API_SHOW_DOMAINS
testing output
[B]HTTP::Request=HASH(0xa332e94)[/B]
not sure how to process/handle that "HASH" result

the same command in my browser, gives back a pure text file with 1 line of text (so even not an HTML file, just pure text)
which is what I would like to get through the command line perl script also

L.
 
Last edited:
In my example script that you quote after "use HTTP::Request::Common qw(GET);"

use

Code:
use LWP::UserAgent;
use HTTP::Cookies;
$ua = new LWP::UserAgent;
$ua->cookie_jar(HTTP::Cookies->new);

then after "my $req = GET $url;"

Code:
@results = $ua->request($req)->as_string;

then you can do something with the @results array.
 
edited

but seems cannot run ........

PHP:
<?php 

include 'httpsocket.php'; 

$sock = new HTTPSocket; 
$sock->connect('ssl://202.181.1XX.182',2222); 

$sock->set_login("2","2"); 

$sock->set_method('POST'); 

$sock->query('/CMD_API_ACCOUNT_USER', 
	array(
        'username' => $_POST['username'], // The User's username. 4-8 characters, alphanumeric 
        'email' => $_POST['email'], // A valid email address 
        'passwd' => $_POST['pwd'], // The User's password. 5+ characters, ascii 
        'passwd2' => $_POST['pwd2'], // Password double check. 5+ characters, ascii 
        'domain' => $_POST['domain'], // A valid domain name in the form: domain.com 
        'package' => $_POST['package'], // One of the User packages created by the Reseller 
        'ip' => '202.181.178.182', // One of the ips which is available for user creation. Only free or shared ips are allowed. 
        'notify' => 'yes', // yes or no. If yes, an email will be sent to email 
        'action' => 'create', 
        'add' => 'Submit' 
    ));

$result = $sock->fetch_body(); 

echo $result; 

?> 

<form method='post' name='form'>
<div align="center">
  <table width="600" border="0" cellpadding="0" cellspacing="0" bordercolor="#333333">
    <tr>
      <td width="300"><div align="center">Username* :</div></td>
      <td width="300">
        <div align="justify">
          <input name='username' type='text' style="WIDTH: 300px" />
        </div></td>
    </tr>
    <tr>
      <td><div align="center">Email :</div></td>
      <td>
        <div align="justify">
          <input name='email' type='text' style="WIDTH: 300px" />
        </div></td>
    </tr>
    <tr>
      <td><div align="center">Password** :</div></td>
      <td>
        <div align="justify">
          <input name='pwd' type='password' style="WIDTH: 300px" />
        </div></td>
    </tr>
    <tr>
      <td><div align="center">Password Validate** :</div></td>
      <td>
        <div align="justify">
          <input name='pwd2' type='password' style="WIDTH: 300px" />
        </div></td>
    </tr>
    <tr>
      <td><div align="center">Domain :</div></td>
      <td>
        <div align="justify">
          <input type="text" name='domain' style="WIDTH: 300px" />
        </div></td>
    </tr>
    <tr>
      <td><div align="center">Bandwidth :</div></td>
      <td> <div align="center">10 GB + </div></td>
    </tr>
    <tr>
      <td bordercolor="#666666"><div align="center">Package :</div></td>
      <td bordercolor="#666666"><div align="center">
          <input type="radio" value='on' name='package' checked="checked" />
        PL1000
        <input type="radio" value='off' name='package' />
        PL500 </div></td>
    </tr>
    <tr>
      <td colspan="2" bordercolor="#666666"><div align="center">
          <input name="submit" type="submit" value='Submit' />
          <br />
        * 4-8 Characters, alphanumeric<br />
        ** 5+ Characters, alphanumeric<br />
       </div></td>
    </tr>
  </table>
</div>
<div align="center"></div>
</form>

Would it have something to do with this line...?
$sock->connect('ssl://202.181.1XX.182',2222);

https:// was used in your first example, and has since been changed to ssl://
I don't know if that makes a difference, but just an idea.

**EDIT**
Also, are you trying to have the HTML form show up before the PHP is processed? So you can fill in values for PHP to use, etc.

~ebauman
 
Last edited:
Back
Top