Hey Tim, It seems that deleteObject takes in 2 params, and you are sending it 1 param. I would recommend you look at the documentation and make sure you are sending the right params. Aziz On Sun, Sep 29, 2013 at 10:29 PM, Tim Dunphy <bluethundr@xxxxxxxxx> wrote: > Hi Aziz, > > Thank you for getting back to me! > > I appreciate you spotting that error. > > So I corrected that > > <?php > require_once 'sdk.class.php'; > if (isset($_POST['submit'])) { > > * $bucket_name = $_POST['bucket_name'];* > > // Create the S3 Object from the SDK > $s3 = new AmazonS3(); > * > $result = $s3->deleteObject(array( > 'Bucket' => $bucket_name ));* > > > // The response comes back as a Simple XML Object > // In this case we just want to know if everything was okay. > // If not, report the message from the XML response. > if ((int) $response->isOK()) { > echo '<center>Deleted Bucket'; > echo '<br /><br />'; > echo '<a href=listbuckets.php>List Buckets</a></center>'; > } else { > echo (string) $response->body->Message; > } > //echo '<br /><br />'; > } > ?> > <body> > <center><h3>Delete S3 Bucket</h3> > <form name="delete_bucket" method="post" action="delete_bucket.php"> > <label for="bucket_name">Bucket Name:</label><br /> > * <input type="text" id="bucket_name" name="bucket_name" /><br /><br /> > * > <input type="submit" name="submit" value="Delete Bucket" /> > </form></center> > <script> > </body> > </html> > > > And this is the error I am currently getting: > > > Warning: Missing argument 2 for AmazonS3::delete_object() in > /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined > variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 > Warning: preg_match() expects parameter 2 to be string, array given in > /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() > expects parameter 2 to be string, array given in > /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught > exception 'S3_Exception' with message 'S3 does not support "Array" as a > valid bucket name. Review "Bucket Restrictions and Limitations" in the S3 > Developer Guide for more information.' in > /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 > /var/www/awssdk/services/s3.class.php(1594): AmazonS3->authenticate(Array, > Array) #1 [internal function]: AmazonS3->delete_object(Array) #2 > /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 > /var/www/awssdk/delete_bucket.php(72): CFRuntime->__call('deleteObject', > Array) #4 /var/www/awssdk/delete_bucket.php(72): > AmazonS3->deleteObject(Array) #5 {main} thrown in > /var/www/awssdk/services/s3.class.php on line 548 > > Not sure if I'm getting closer here... but definitely appreciate any > advice anyone may have. > > Thanks! > Tim > > > On Sun, Sep 29, 2013 at 5:04 PM, Aziz Saleh <azizsaleh@xxxxxxxxx> wrote: > >> No Problem, the issue is that you referring to the invalid post element >> $bucket_name as opposed to the correct on bucket_name. >> >> *$bucket_name = $_POST['$bucket_name'];* >> >> Should be >> >> *$bucket_name = $_POST['bucket_name'];* >> >> Aziz >> >> >> On Sun, Sep 29, 2013 at 3:28 PM, Tim Dunphy <bluethundr@xxxxxxxxx> wrote: >> >>> Hey guys, >>> >>> Sorry about that i should have posted the full code to give you some >>> idea of context. Anyway, here it is: >>> >>> <?php >>> require_once 'sdk.class.php'; >>> if (isset($_POST['submit'])) { >>> >>> * $bucket_name = $_POST['$bucket_name'];* >>> // Create the S3 Object from the SDK >>> *$s3 = new AmazonS3();* >>> >>> * $result = $s3->deleteObject(array(* >>> * 'Bucket' => $bucket_name ));* >>> >>> >>> // The response comes back as a Simple XML Object >>> // In this case we just want to know if everything was okay. >>> // If not, report the message from the XML response. >>> if ((int) $response->isOK()) { >>> echo '<center>Deleted Bucket'; >>> echo '<br /><br />'; >>> echo '<a href=listbuckets.php>List Buckets</a></center>'; >>> } else { >>> echo (string) $response->body->Message; >>> } >>> //echo '<br /><br />'; >>> } >>> ?> >>> <body> >>> <center><h3>Delete S3 Bucket</h3> >>> <form name="delete_bucket" method="post" action="delete_bucket.php"> >>> <label for="bucket_name">Bucket Name:</label><br /> >>> * <input type="text" id="bucket_name" name="bucket_name" /><br /><br >>> />* >>> <input type="submit" name="submit" value="Delete Bucket" /> >>> </form></center> >>> >>> So, as you can see I am taking the 'bucket_value' from $_POST and >>> passing it into the call to S3. >>> >>> When the form comes up on the web I give it the name of one of my S3 >>> buckets. The result is the following error: >>> >>> Notice: Undefined index: $bucket_name in >>> /var/www/awssdk/delete_bucket.php on line 67 Warning: Missing argument 2 >>> for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on >>> line 1576 Notice: Undefined variable: filename in >>> /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() >>> expects parameter 2 to be string, array given in >>> /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() >>> expects parameter 2 to be string, array given in >>> /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught >>> exception 'S3_Exception' with message 'S3 does not support "Array" as a >>> valid bucket name. Review "Bucket Restrictions and Limitations" in the S3 >>> Developer Guide for more information.' in >>> /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 >>> /var/www/awssdk/services/s3.class.php(1594): AmazonS3->authenticate(Array, >>> Array) #1 [internal function]: AmazonS3->delete_object(Array) #2 >>> /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 >>> /var/www/awssdk/delete_bucket.php(72): CFRuntime->__call('deleteObject', >>> Array) #4 /var/www/awssdk/delete_bucket.php(72): >>> AmazonS3->deleteObject(Array) #5 {main} thrown in >>> /var/www/awssdk/services/s3.class.php on line 548 >>> >>> >>> >>> I hope that clarifies my situation a bit. Sorry for not providing that >>> sooner! >>> >>> Thanks >>> Tim >>> >>> >>> On Sun, Sep 29, 2013 at 1:09 PM, Aziz Saleh <azizsaleh@xxxxxxxxx> wrote: >>> >>>> Hi Tim, >>>> >>>> Is the call working? Does it actually get deleted? >>>> >>>> This could just be an issue (which I see alot) where developers do not >>>> check for variables or preset them before usage, causing those notices to >>>> come up (pretty harmless most of the times). >>>> >>>> Aziz >>>> >>>> >>>> On Sun, Sep 29, 2013 at 12:30 PM, Tim Dunphy <bluethundr@xxxxxxxxx>wrote: >>>> >>>>> Hi All, >>>>> >>>>> I am attempting to delete an empty S3 bucket using the AWS PHP SDK. >>>>> >>>>> Here's how they describe the process in the docs: >>>>> >>>>> $result = $client->deleteBucket(array( >>>>> // Bucket is required >>>>> 'Bucket' => 'string', >>>>> )); >>>>> >>>>> You can find the full entry here: >>>>> >>>>> AWS PHP SDK Delete Bucket >>>>> Docs< >>>>> http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_deleteBucket >>>>> > >>>>> >>>>> >>>>> Here's how I approached it in my code: >>>>> >>>>> $s3 = new AmazonS3(); >>>>> >>>>> $result = $s3->deleteObject(array( >>>>> 'Bucket' => $bucket_name )); >>>>> >>>>> But when I run it, this is the error I get: >>>>> >>>>> 'Notice: Undefined index: $bucket_name in >>>>> /var/www/awssdk/delete_bucket.php >>>>> on line 5 Warning: Missing argument 2 for AmazonS3::delete_object() in >>>>> /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined >>>>> variable: filename in /var/www/awssdk/services/s3.class.php on line >>>>> 1581 >>>>> Warning: preg_match() expects parameter 2 to be string, array given in >>>>> /var/www/awssdk/services/s3.class.php on line 1042 Warning: >>>>> preg_match() >>>>> expects parameter 2 to be string, array given in >>>>> /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: >>>>> Uncaught >>>>> exception 'S3_Exception' with message 'S3 does not support "Array" as a >>>>> valid bucket name. Review "Bucket Restrictions and Limitations" in the >>>>> S3 >>>>> Developer Guide for more information.' in >>>>> /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 >>>>> /var/www/awssdk/services/s3.class.php(1594): >>>>> AmazonS3->authenticate(Array, >>>>> Array) #1 [internal function]: AmazonS3->delete_object(Array) #2 >>>>> /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) >>>>> #3 >>>>> /var/www/awssdk/delete_bucket.php(10): >>>>> CFRuntime->__call('deleteObject', >>>>> Array) #4 /var/www/awssdk/delete_bucket.php(10): >>>>> AmazonS3->deleteObject(Array) #5 {main} thrown in >>>>> /var/www/awssdk/services/s3.class.php on line 548' >>>>> >>>>> >>>>> This is line 548 in the above referenced file: >>>>> >>>>> // Validate the S3 bucket name >>>>> if (!$this->validate_bucketname_support($bucket)) >>>>> { >>>>> // @codeCoverageIgnoreStart >>>>> throw new S3_Exception('S3 does not support "' >>>>> . >>>>> $bucket . '" as a valid bucket name. Review "Bucket Restrictions and >>>>> Limitations" in the S3 Developer Guide for more information.'); >>>>> // @codeCoverageIgnoreEnd >>>>> } >>>>> >>>>> >>>>> >>>>> >>>>> Has anyone played around enough with the AWS SDK to know what I'm doing >>>>> wrong here? Would anyone else be able to hazard a guess? >>>>> >>>>> Thanks >>>>> Tim >>>>> -- >>>>> GPG me!! >>>>> >>>>> gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B >>>>> >>>> >>>> >>> >>> >>> -- >>> GPG me!! >>> >>> gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B >>> >>> >> > > > -- > GPG me!! > > gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B > >