Ok... I did some changes, now I'm able to see both username and
aliases and pass that to the php, but I get these errors:
Attempting to get token...
Obtained token
Giving username1 email alias email.alias1
...
<?xml version="1.0" encoding="UTF-8"?>
<hs:rest
xmlns:hs="google:accounts:rest:protocol"><hs:status>Failure(2001)</
hs:status><hs:reason>BadRequest(1016)</
hs:reason><hs:extendedMessage>No extended message available for this
error.</hs:extendedMessage><hs:result></hs:result><hs:type></hs:type></
hs:rest>
and like that for every user....
Thanks again for any help.
Here is my updated code:
::::::::::::::
get_users_jnum_test.sh
::::::::::::::
#!/bin/bash
#for line1 in $(more user_list.txt |gawk '{print $1}')
#do
#echo user $line1 has alias $(more user_list.txt |grep $line1 | gawk
'{print $2}')
#done
more user_list_test.txt | xargs -l1 /usr/bin/php my_test.php
::::::::::::::
user_list_test.txt
::::::::::::::
userid1 email.alias1
userid2 email.alias2
userid3 email.alias3
...
...
...
::::::::::::::
my_test.php
:::::::::::::::
#!/usr/bin/php4 -q
<?php
require_once("auth.php");
require_once("account.php");
require_once("alias.php");
require_once("mailing.php");
/* Example user name, alias name and mailing list name for the demo.
*/
$user_name = $argv[1];
$alias_name = `more user_list_test.txt |grep '$user_name' |awk
'{print $2}'`;
/* Get an administrator token. */
print "Attempting to get token...\n";
$token = GetAuthToken("[EMAIL PROTECTED]", "mypassword",
"", "");
print "Obtained token $token\n\n";
/* And an email alias. */
print "Giving " . $user_name . " email alias " . $alias_name . "...
\n";
print CreateAlias($token, "voffice.jsums.edu", $user_name,
$alias_name) . "\n";
?>
::::::::::::::::::
get_users_test.sh
:::::::::::::::::::::
#!/bin/bash
more user_list_test.txt | gawk '{print $1}' | xargs -l1 /usr/bin/php
my_test.php
On Apr 28, 9:38 am, rama1200 <[EMAIL PROTECTED]> wrote:
> Woohoo!
> Thanks, that did it!
>
> $user_name = $argv[1];
> and
> $alias_name = $prefix.$user_name;
>
> I will keep playing with this and see what other trouble I can get
> myself into.
>
> I love to see <hs:status>Success(2000)</hs:status>
>
> Thanks,
>
> On Apr 25, 11:17 am, "Q (Google)" <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi,
>
> > Thank you for including all the sources needed to reproduce the
> > problem in your original post. I have a few suggestions:
>
> > Replace the line
> > $user_name = $ARGV[0];
> > with
> > $user_name = $argv[1];
> > in my_test.php
>
> > Variables are case sensitive in PHP. Also, the index 0 refers to the
> > program/command (in this case "my_test.php") and the index 1
> > corresponds to the first argument. To see the values of $argv, try
> > adding var_dump($argv); to my_test.php.
>
> > If you find your shell script get_users_jnum_test.sh stops after just
> > the first user name, you may try replacing
> > cat user_list_test.txt | xargs /usr/bin/php my_test.php
> > with
> > cat user_list_test.txt | while read name; do /usr/bin/php
> > my_test.php $name; done
>
> > Finally, to keep alias names unique, you'll probably want to assign
> > $alias_name to something more dynamic if you are going to run this for
> > more than one user. Otherwise you may run into UserAlreadyExists
> > failures. Here's one simple way:
> > ...
> > $prefix = "test";
> > $alias_name = $prefix.$user_name;
> > ...
>
> > Cheers,
> > Q
>
> > On Apr 24, 9:56 am, rama1200 <[EMAIL PROTECTED]> wrote:
>
> > > I downloaded the provisioning-api, zend and php library, etc. I've
> > > changed the code to fit my domain... I'm trying to test creating
> > > multiple aliases/nicknames for existing users... when the provided
> > > php
> > > code tries with a single user, it works; the code goes to gmail,
> > > downloads a tocken, and changed/adds a nickname for that user.
>
> > > Now, I'm trying the same, but I'm trying to pass the $user_name
> > > ="someusername"; taking it from a text file with one username per
> > > line... in the README sample code to create/change aliases sample code
> > > that comes with the provisioning-api-php, I changed the :
> > > $user_name = $ARGV[0];
> > > $alias_name = "test.alias2";
>
> > > and off course all the domain parameters to match mine...
>
> > > I also have a .sh script with this:
> > > #!/bin/bash
> > > more user_list_test.txt | xargs -l1 /usr/bin/php my_test.php
>
> > > which is supposed to pass the usernames (one by one) to the php code,
> > > but when I run the bash (which also runs the php), I get:
>
> > > #!/usr/bin/php4 -q
>
> > > PHP Notice: Undefined variable: ARGV in /root/provisioning-api-php/
> > > php/my_test.php on line 31
> > > Attempting to get token...
> > > Obtained token
>
> > > Giving email alias test.alias2...
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <hs:rest
> > > xmlns:hs="google:accounts:rest:protocol"><hs:status>Failure(2001)</
> > > hs:status><hs:reason>UserDoesNotExist(1009)</
> > > hs:reason><hs:extendedMessage>No extended message available for this
> > > error.</hs:extendedMessage><hs:result></hs:result><hs:type></hs:type></
> > > hs:rest>
>
> > > #!/usr/bin/php4 -q
>
> > > PHP Notice: Undefined variable: ARGV in /root/provisioning-api-php/
> > > php/my_test.php on line 31
> > > Attempting to get token...
> > > Obtained token
>
> > > Giving email alias test.alias2...
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <hs:rest
> > > xmlns:hs="google:accounts:rest:protocol"><hs:status>Failure(2001)</
> > > hs:status><hs:reason>UserDoesNotExist(1009)</
> > > hs:reason><hs:extendedMessage>No extended message available for this
> > > error.</hs:extendedMessage><hs:result></hs:result><hs:type></hs:type></
> > > hs:rest>
>
> > > etc. etc.
>
> > > How to tell the php code to read the usernames from an external
> > > source?
>
> > > I think I've tried it all, but not luck.
>
> > > Thanks a bunch:
>
> > > Code follows:
>
> > > ::::::::::::::
> > > get_users_jnum_test.sh
> > > ::::::::::::::
> > > #!/bin/bash
> > > more user_list_test.txt | xargs -l1 /usr/bin/php my_test.php
>
> > > ::::::::::::::
> > > user_list_test.txt
> > > ::::::::::::::
> > > username1
> > > username2
> > > username3
> > > username4
> > > username5
>
> > > ::::::::::::::
> > > my_test.php
> > > ::::::::::::::
> > > #!/usr/bin/php4 -q
>
> > > <?php
>
> > > /**
> > > * Copyright (C) 2006 Google Inc.
> > > *
> > > * Licensed under the Apache License, Version 2.0 (the "License");
> > > * you may not use this file except in compliance with the License.
> > > * You may obtain a copy of the License at
> > > *
> > > * http://www.apache.org/licenses/LICENSE-2.0
> > > *
> > > * Unless required by applicable law or agreed to in writing,
> > > software
> > > * distributed under the License is distributed on an "AS IS" BASIS,
> > > * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > > implied.
> > > * See the License for the specific language governing permissions
> > > and
> > > * limitations under the License.
> > > */
>
> > > require_once("auth.php");
> > > require_once("account.php");
> > > require_once("alias.php");
> > > require_once("mailing.php");
>
> > > //$get_user = `sh get_users_jnum_test.sh`;
>
> > > //$ARGV = `more user_list_test.txt | xargs -l1 /usr/bin/php
> > > my_test.php`;
>
> > > /* Example user name, alias name and mailing list name for the demo.
> > > */
> > > $user_name = $ARGV[0];
> > > $alias_name = "test.alias2";
> > > //$mailing_list_name = "my-list-example";
>
> > > /* Get an administrator token. */
> > > print "Attempting to get token...\n";
> > > $token = GetAuthToken("[EMAIL PROTECTED]", "password-goes-
> > > here",
> > > "", "");
> > > print "Obtained token $token\n\n";
>
> > > /* And an email alias. */
> > > print "Giving " . $user_name . " email alias " . $alias_name . "...
> > > \n";
> > > print CreateAlias($token, "mydomain", $user_name, $alias_name) .
> > > "\n";
>
> > > ?>- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Apps APIs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-apps-apis?hl=en
-~----------~----~----~----~------~----~------~--~---