Welcome Guest, Not a member yet? Register   Sign In
Curl request
#21

(This post was last modified: 07-08-2024, 03:14 AM by pippuccio76.)

(07-08-2024, 02:23 AM)kenjis Wrote: If you don't know how to send a correct request, nobody cannot help you.
Why don't you ask to the technical support of the api provider?

I don't know how to translate this :

Code:
curl -X POST --user '<CLIENT_ID>:<CLIENT_SECRET>' -H 'Content-Type: application/x-www-form-urlencoded' 'https://dispatchapi-sandbox-qa.auth.eu-west-1.amazoncognito.com/oauth2/token?grant_type=client_credentials'




to ci code ....

The api is written from booking.com developer  I think it works
Reply
#22

(This post was last modified: 07-08-2024, 04:30 AM by kenjis.)

If the following command works, show the debug output and know all the request headers.
Code:
curl -X POST --user '<CLIENT_ID>:<CLIENT_SECRET>' -H 'Content-Type: application/x-www-form-urlencoded' 'https://dispatchapi-sandbox-qa.auth.eu-west-1.amazoncognito.com/oauth2/token?grant_type=client_credentials'

After that, configure the options that send the exact same request headers.
All options are shown in https://codeigniter.com/user_guide/libra...st-options
Reply
#23

(This post was last modified: 07-08-2024, 05:12 AM by pippuccio76.)

(07-08-2024, 04:30 AM)kenjis Wrote: If the following command works, show the debug output and know all the request headers.
Code:
curl -X POST --user '<CLIENT_ID>:<CLIENT_SECRET>' -H 'Content-Type: application/x-www-form-urlencoded' 'https://dispatchapi-sandbox-qa.auth.eu-west-1.amazoncognito.com/oauth2/token?grant_type=client_credentials'

After that, configure the options that send the exact same request headers.
All options are shown in https://codeigniter.com/user_guide/libra...st-options
can i use this command :



Code:
curl -X POST --user '<CLIENT_ID>:<CLIENT_SECRET>' -H 'Content-Type: application/x-www-form-urlencoded' 'https://dispatchapi-sandbox-qa.auth.eu-west-1.amazoncognito.com/oauth2/token?grant_type=client_credentials'






directly in controller method ?
Reply
#24

i transform with a online script :
Code:
        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, 'https://dispatchapi-sandbox-qa.auth.eu-west-1.amazoncognito.com/oauth2/token?grant_type=client_credentials');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_USERPWD, $client_id . ':' . $client_secret);

        $headers = array();
        $headers[] = 'Content-Type: application/x-www-form-urlencoded';
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

        $result = curl_exec($ch);

        if (curl_errno($ch)) {
            echo 'Error:' . curl_error($ch);
        }

        curl_close($ch);

        //$info = curl_getinfo($ch);


        dd($result);

it work :
Code:
access_token => string (975) "eyJraWQiOiJVRFcwVzJwRUFrNCtxakdhRVUxOFA0ZStjSlNiQjRmQnA2dl........................
expires_in => integer 3600
token_type => string (6) "Bearer"
Is there a way to trasform in ci ?
Reply
Reply




Theme © iAndrew 2016 - Forum software by © MyBB