2019-04-16 20:49:53 -07:00
< ? php
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
2024-01-16 10:41:11 -05:00
2019-04-16 20:49:53 -07:00
/**
* ABOUT THIS PHP SAMPLE: This sample is part of the SDK for PHP Developer Guide topic at
* https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/iam-examples-working-with-policies.html
*
*/
// snippet-start:[cognito.php.user_pool.create_user_pool_client.complete]
// snippet-start:[cognito.php.user_pool.create_user_pool_client.import]
require 'vendor/autoload.php' ;
use Aws\CognitoIdentityProvider\CognitoIdentityProviderClient ;
use Aws\Exception\AwsException ;
// snippet-end:[cognito.php.user_pool.create_user_pool_client.import]
/**
* Creates a new User Pool Client for your AWS account.
*
* This code expects that you have AWS credentials set up per:
* https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/guide_credentials.html
*/
// snippet-start:[cognito.php.user_pool.create_user_pool_client.main]
2024-02-05 10:49:20 -07:00
2019-04-16 20:49:53 -07:00
$client = new CognitoIdentityProviderClient ([
'profile' => 'default' ,
'region' => 'us-east-2' ,
'version' => '2016-04-18'
]);
$clientName = " PHP_SDK_test_client " ;
$userPoolId = " us-east-2_P0oL1D " ;
try {
$result = $client -> createUserPoolClient ([
'ClientName' => $clientName ,
'UserPoolId' => $userPoolId ,
]);
echo $result [ " UserPoolClient " ][ " ClientId " ];
var_dump ( $result );
} catch ( AwsException $e ) {
// output error message if fails
echo $e -> getMessage () . " \n " ;
error_log ( $e -> getMessage ());
}
// snippet-end:[cognito.php.user_pool.create_user_pool_client.main]
// snippet-end:[cognito.php.user_pool.create_user_pool_client.complete]
// snippet-sourceauthor:[jschwarzwalder (AWS)]