Communicating with a Rest API through PHP - how to process?

365 views Asked by At

I have been trying to use the Stormpath API in my website. I cannot work out how to communicate with the API through PHP. I've tried some variations of cURL but I think I'm missing something...At this stage I'm just trying to make the request from a blank page with known account details - I'm not getting any result.

The API documentation provides this example, for example. What is the simplest way for me to submit the request this using PHP?

Request

POST /oauth/token HTTP/1.1
Accept: application/json
Content-Type: application/x-www-form-urlencoded
Host: smooth-ensign.apps.stormpath.io

grant_type=password&username=jakub%40stormpath.com&password=Password1%21

Response

{
  "access_token": "eyJraWQi[...]0dTpiM",
  "refresh_token": "eyJraWQi[...]okvVI",
  "token_type": "Bearer",
  "expires_in": 3600
}

I also have the Stormpath PHP SDK installed, if that provides a better way to do this.

0

There are 0 answers