<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://api-wiki.apps.rackspace.com/api-wiki/index.php?action=history&amp;feed=atom&amp;title=PHPAddSubaccounts</id>
		<title>PHPAddSubaccounts - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://api-wiki.apps.rackspace.com/api-wiki/index.php?action=history&amp;feed=atom&amp;title=PHPAddSubaccounts"/>
		<link rel="alternate" type="text/html" href="http://api-wiki.apps.rackspace.com/api-wiki/index.php?title=PHPAddSubaccounts&amp;action=history"/>
		<updated>2026-05-02T11:27:38Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.29.1</generator>

	<entry>
		<id>http://api-wiki.apps.rackspace.com/api-wiki/index.php?title=PHPAddSubaccounts&amp;diff=212&amp;oldid=prev</id>
		<title>APIAdmin: New page: Copy and paste this script into an empty file, then make it executable (*nix).  It works with PHP that has compiled SOAP support.&lt;br&gt;&lt;br&gt;  &lt;pre&gt; &lt;?php  ####################################...</title>
		<link rel="alternate" type="text/html" href="http://api-wiki.apps.rackspace.com/api-wiki/index.php?title=PHPAddSubaccounts&amp;diff=212&amp;oldid=prev"/>
				<updated>2008-08-25T23:58:57Z</updated>
		
		<summary type="html">&lt;p&gt;New page: Copy and paste this script into an empty file, then make it executable (*nix).  It works with PHP that has compiled SOAP support.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;  &amp;lt;pre&amp;gt; &amp;lt;?php  ####################################...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Copy and paste this script into an empty file, then make it executable (*nix).  It works with PHP that has compiled SOAP support.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
#################################################################&lt;br /&gt;
#                                                               #&lt;br /&gt;
#  This script will create subaccounts from a list              #&lt;br /&gt;
#                                                               #&lt;br /&gt;
#################################################################&lt;br /&gt;
&lt;br /&gt;
$debug=false;&lt;br /&gt;
&lt;br /&gt;
if(($argv[1]==&amp;quot;-h&amp;quot;)||($argv[1]==&amp;quot;--help&amp;quot;)||(count($argv)&amp;lt;4)||(count($argv)&amp;gt;5)) {&lt;br /&gt;
  echo &amp;quot;PHP script to create a list of accounts for a Webmail.us reseller\n&amp;quot;;&lt;br /&gt;
  echo &amp;quot;Created April 2007 by Kirk Averett\n&amp;quot;;&lt;br /&gt;
  echo &amp;quot;\n&amp;quot;;&lt;br /&gt;
  echo &amp;quot;Usage:\n&amp;quot;;&lt;br /&gt;
  echo &amp;quot;php &amp;quot;.$argv[0].&amp;quot; filename username password [optional separator value] \n&amp;quot;;&lt;br /&gt;
  echo &amp;quot;\n&amp;quot;;&lt;br /&gt;
  echo &amp;quot;The username and password should be for an admin login to a reseller account\n&amp;quot;;&lt;br /&gt;
  echo &amp;quot;The filename should be the file with the list of account names to be created\n&amp;quot;;&lt;br /&gt;
  echo &amp;quot;'\\n' is the default separator, meaning that each account appears on a separate line\n&amp;quot;;&lt;br /&gt;
  echo &amp;quot;\n&amp;quot;;&lt;br /&gt;
  exit;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
array_shift($argv);&lt;br /&gt;
$file=array_shift($argv);&lt;br /&gt;
$ruser=array_shift($argv);&lt;br /&gt;
$rpass=array_shift($argv);&lt;br /&gt;
if(count($argv)==1) {&lt;br /&gt;
  $sep = $argv[0];&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
  $sep = &amp;quot;\n&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
$wsdl=&amp;quot;https://admin.webmail.us/excedentsoap/excedentsoap.wsdl&amp;quot;;&lt;br /&gt;
$client = new SoapClient($wsdl, array('trace' =&amp;gt; true, 'exceptions' =&amp;gt; true));&lt;br /&gt;
&lt;br /&gt;
$accounts_string=trim(file_get_contents($file));&lt;br /&gt;
$accounts_array = explode($sep,$accounts_string); &lt;br /&gt;
&lt;br /&gt;
$num = count($accounts_array);&lt;br /&gt;
for ($i=0; $i&amp;lt;$num; $i++) {&lt;br /&gt;
  $currentaccount = trim($accounts_array[$i]);&lt;br /&gt;
  if($currentaccount==&amp;quot;&amp;quot;) { continue; }&lt;br /&gt;
  $res = $client-&amp;gt;__soapCall('SearchSubaccounts',&lt;br /&gt;
                       array('ResellerUsername' =&amp;gt; $ruser,&lt;br /&gt;
                             'ResellerPassword' =&amp;gt; $rpass,&lt;br /&gt;
                             'SubaccountName'   =&amp;gt; $currentaccount,&lt;br /&gt;
                             'accountList'      =&amp;gt; &amp;quot;&amp;quot;));&lt;br /&gt;
  if ($res[Result] == 1) {  }&lt;br /&gt;
  else { echo &amp;quot;Couldn't search for account &amp;quot;.$currentaccount.&amp;quot; with error:\n&amp;quot;; print_r($res); echo &amp;quot;\n&amp;quot;; }&lt;br /&gt;
  $subfound = true;&lt;br /&gt;
  if ($res[accountList] == &amp;quot;&amp;quot;) { $subfound = false; }&lt;br /&gt;
  else {&lt;br /&gt;
    $subacclistarr = explode(&amp;quot;\n&amp;quot;,$res[accountList]);&lt;br /&gt;
    list($subnum,$subname) = explode(&amp;quot;,&amp;quot;,$subacclistarr[0]);&lt;br /&gt;
    if(!(trim($subname) == $currentaccount)) { $subfound = false; }&lt;br /&gt;
  }&lt;br /&gt;
  if($subfound == false) { // Add subaccount&lt;br /&gt;
    $res = $client-&amp;gt;__soapCall('AddSubaccount',&lt;br /&gt;
                         array('ResellerUsername' =&amp;gt; $ruser,&lt;br /&gt;
                               'ResellerPassword' =&amp;gt; $rpass,&lt;br /&gt;
                               'SubaccountName'   =&amp;gt; $currentaccount,&lt;br /&gt;
                               'accountNumber'    =&amp;gt; &amp;quot;&amp;quot;));&lt;br /&gt;
    if ($res[Result] == 1) { echo &amp;quot;New account $currentaccount added to system and identified as #&amp;quot;.$res[accountNumber].&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    elseif ($res[Result] == -200) { echo &amp;quot;Account exists\n&amp;quot;; }&lt;br /&gt;
    else { echo &amp;quot;Could not add &amp;quot;.$currentaccount.&amp;quot; as a new account with error:\n&amp;quot;; print_r($res); echo &amp;quot;\n&amp;quot;;}&lt;br /&gt;
  }&lt;br /&gt;
  else { echo &amp;quot;Account $currentaccount already in system\n&amp;quot;; }&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>APIAdmin</name></author>	</entry>

	</feed>