1. Go to this page and download the library: Download sdksio/usps-apimatic-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sdksio / usps-apimatic-sdk example snippets
use UspsApiLib\Logging\LoggingConfigurationBuilder;
use UspsApiLib\Logging\RequestLoggingConfigurationBuilder;
use UspsApiLib\Logging\ResponseLoggingConfigurationBuilder;
use Psr\Log\LogLevel;
use UspsApiLib\Environment;
use UspsApiLib\Authentication\OauthAuthorizationCodeCredentialsBuilder;
use UspsApiLib\Models\OauthScopeOauthAuthorizationCode;
use UspsApiLib\Authentication\OauthClientCredentialsCredentialsBuilder;
use UspsApiLib\Models\OauthScopeOauthClientCredentials;
use UspsApiLib\Authentication\BasicAuthCredentialsBuilder;
use UspsApiLib\Authentication\BearerTokenAuthCredentialsBuilder;
use UspsApiLib\UspsApiClientBuilder;
$client = UspsApiClientBuilder::init()
->oauthAuthorizationCodeCredentials(
OauthAuthorizationCodeCredentialsBuilder::init(
'OAuthClientId',
'OAuthClientSecret',
'OAuthRedirectUri'
)
->oauthScopes(
[
OauthScopeOauthAuthorizationCode::ADDRESSES,
OauthScopeOauthAuthorizationCode::ADJUSTMENTS
]
)
)
->oauthClientCredentialsCredentials(
OauthClientCredentialsCredentialsBuilder::init(
'OAuthClientId',
'OAuthClientSecret'
)
->oauthScopes(
[
OauthScopeOauthClientCredentials::ADDRESSES,
OauthScopeOauthClientCredentials::ADJUSTMENTS
]
)
)
->basicAuthCredentials(
BasicAuthCredentialsBuilder::init(
'Username',
'Password'
)
)
->bearerTokenAuthCredentials(
BearerTokenAuthCredentialsBuilder::init(
'AccessToken'
)
)
->environment(Environment::PRODUCTION)
->loggingConfiguration(
LoggingConfigurationBuilder::init()
->level(LogLevel::INFO)
->requestConfiguration(RequestLoggingConfigurationBuilder::init()->body(true))
->responseConfiguration(ResponseLoggingConfigurationBuilder::init()->headers(true))
)
->build();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.