PHP에 대한 Akamai Edgegrid 인증
이 라이브러리는 PHP 8+가 필요하며 드롭 인 교체 클라이언트 및 미들웨어로 Guzze 상단의 Akamai Edgegrid 인증 체계를 구현합니다.
설치하려면 composer 사용하십시오.
$ composer require akamai-open/edgegrid-client릴리스 페이지에서 PHAR 파일을 다운로드하고 코드 안에 포함시킵니다.
```php
include 'akamai-open-edgegrid-auth.phar';
// Library is ready to use
```
AkamaiOpenEdgeGridClient GuzzleHttpClient 드롭 인 교체로 확장합니다. Guzzle을 사용하는 다른 방법을 변경하지 않고 API 요청에 서명하는 데 투명하게 작동합니다.
클라이언트를 사용하려면 AkamaiOpenEdgeGridClient->setAuth() 호출하거나 API에 요청하기 전에 생성자에 대한 AkamaiOpenEdgeGridAuthentication 인스턴스를 제공하십시오.
$ client = new Akamai Open EdgeGrid Client ([
' base_uri ' => ' https://akab-h05tnam3wl42son7nktnlnnx-kbob3i3v.luna.akamaiapis.net '
]);
$ client -> setAuth ( $ client_token , $ client_secret , $ access_token );
// use $client just as you would GuzzleHttpClient
$ response = $ client -> get ( ' /identity-management/v3/user-profile ' );자격 증명을 생성하려면 인증 자격 증명 만들기를 참조하십시오.
로컬 .edgerc 인증 파일을 사용하는 것이 좋습니다. 로컬 홈 디렉토리 또는 웹 서버 사용자의 홈 디렉토리에 [default] 제목 아래에 자격 증명을 배치하십시오.
[default]
client_secret = C113nt53KR3TN6N90yVuAgICxIRwsObLi0E67/N8eRN=
host = akab-h05tnam3wl42son7nktnlnnx-kbob3i3v.luna.akamaiapis.net
access_token = akab-acc35t0k3nodujqunph3w7hzp7-gtm6ij
client_token = akab-c113ntt0k3n4qtari252bfxxbsl-yvsdj
.edgerc 파일을 두 가지 방법 중 하나로 호출 할 수 있습니다.
공장 메소드 AkamaiOpenEdgeGridClient::createFromEdgeRcFile() 사용하십시오.
$ client = Akamai Open EdgeGrid Client:: createFromEdgeRcFile ();
// use $client just as you would GuzzleHttpClient
$ response = $ client -> get ( ' /identity-management/v3/user-profile ' ); 자격 증명 섹션 및/또는 .edgerc 위치를 지정하십시오.
$ client = Akamai Open EdgeGrid Client:: createFromEdgeRcFile ( ' example ' , ' ../config/.edgerc ' );
// use $client just as you would GuzzleHttpClient
$ response = $ client -> get ( ' /identity-management/v3/user-profile ' );이 라이브러리는 HTTPIE를 모방하는 제한된 기능 세트가있는 CLI (Command Line Interface)를 제공합니다.
Composer vendor/bin/http 로 CLI를 설치하거나 PHAR 파일을 실행하십시오.
# Composer installed
$ ./vendor/bin/http --help
# For Windows
> php ./vendor/bin/http --help
# PHAR download
php akamai-open-edgegrid-client.phar --help인증을 설정하고 HTTP 메소드 (Case Insensitive), 헤더 및 JSON 바디 필드를 지정할 수 있습니다.
참고 : 우리의 CLI에는 모든 HTTP 및 신체 데이터가 표시됩니다. JSON이 형성됩니다.
| 논쟁 | 설명 |
|---|---|
--auth-type={edgegrid,basic,digest} | 인증 유형을 설정하십시오. 기본값은 none 입니다. |
--auth user: 또는 --a user: | 사용할 .edgerc 섹션을 설정하십시오. httpie-edgegrid 와 달리 결장 ( : 은 선택 사항입니다. |
Header-Name:value | 헤더와 값은 결장 ( : 분리되어 있습니다. |
jsonKey=value | POST 또는 PUT 본문에서 {"jsonKey": "value"} 보냅니다. 또한 Content-Type 자동으로 설정하고 헤더를 application/json 으로 Accept . |
jsonKey:=[1,2,3] | RAW JSON 데이터를 지정하여 신체에 {"jsonKey": [1, 2, 3]} 보낼 수 있습니다. |
multipart/mime (파일 업로드) 데이터를 보낼 수 없습니다. 이 패키지는 Client 사용할 때 투명하게 추가 할 수있는 세 가지 미들웨어 핸들러, 표준 GuzzleHttpClient 또는 핸들러에 투명하게 추가 할 수 있습니다.
AkamaiOpenEdgeGridHandlerAuthentication .AkamaiOpenEdgeGridHandlerVerbose .AkamaiOpenEdgeGridHandlerDebug .| 매니저 | 부르다 |
|---|---|
Authentication | Client->setAuthentication() 또는 AkamaiEdgeGridAuthentication on Client->__construct() 의 인스턴스에서 전달됩니다. |
Verbose | Client->setInstanceVerbose() 또는 Client::setVerbose() `true를 통과합니다 |
Debug | Client->setInstanceDebug() , Client::setDebug() 또는`true로 debug 구성 옵션을 설정하십시오. |
| 매니저 | 예 |
|---|---|
| 입증 | // Create the Authentication Handler
$ auth = Akamai Open EdgeGrid Handler Authentication:: createFromEdgeRcFile ();
// or:
$ auth = new Akamai Open EdgeGrid Handler Authentication ;
$ auth -> setAuth ( $ client_token , $ client_secret , $ access_token );
// Create the handler stack
$ handlerStack = GuzzleHttp HandlerStack:: create ();
// Add the Auth handler to the stack
$ handlerStack -> push ( $ auth );
// Add the handler to a regular GuzzleHttpClient
$ guzzle = new GuzzleHttp Client ([
" handler " => $ handlerStack
]); |
| 말 수가 많은 | // Create the handler stack
$ handlerStack = HandlerStack:: create ();
// Add the Auth handler to the stack
$ handlerStack -> push ( new Akamai Open EdgeGrid Handler Verbose ());
// Add the handler to a regular GuzzleHttpClient
$ guzzle = new GuzzleHttp Client ([
" handler " => $ handlerStack
]); // Create the handler stack
$ handlerStack = HandlerStack:: create ();
// Add the Auth handler to the stack
$ handlerStack -> push ( new Akamai Open EdgeGrid Handler Debug ());
// Add the handler to a regular GuzzleHttpClient
$ guzzle = new GuzzleHttp Client ([
" handler " => $ handlerStack
]); |
Copyright © 2022 Akamai Technologies, Inc. 모든 권리 보유
Apache 라이센스, 버전 2.0 ( "라이센스")에 따라 라이센스가 부여되었습니다. 라이센스를 준수하는 것 외에는이 파일을 사용할 수 없습니다. http://www.apache.org/licenses/license-2.0에서 라이센스 사본을 얻을 수 있습니다.
해당 법률에 의해 요구되거나 서면에 동의하지 않는 한, 라이센스에 따라 배포 된 소프트웨어는 명시 적 또는 묵시적 보증 또는 조건없이 "그대로"기준으로 배포됩니다. 라이센스에 따른 특정 언어 통치 권한 및 제한 사항에 대한 라이센스를 참조하십시오.