Raj
Raj

Reputation: 29

Convert curl command to PHP

Iam using MX API and want to convert curl command to php. The command is as follows:

curl -i -X GET 'https://vestibule.mx.com/institutions' \
-H 'Accept: application/vnd.mx.atrium.v1+json' \
-H 'MX-API-Key: de9f1ed2-6332-ff80-0493-11ea9952cfb3' \
-H 'MX-Client-ID: c3d38602-3a95-401f-9116-8fcedfa87dfd'

Any help would be highly appreciated

Upvotes: 0

Views: 90

Answers (2)

user3064538
user3064538

Reputation:

Paste your curl command into curlconverter.com/php/ and it will convert it into this PHP code using PHP's cURL integration:

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://vestibule.mx.com/institutions');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Accept' => 'application/vnd.mx.atrium.v1+json',
    'MX-API-Key' => 'de9f1ed2-6332-ff80-0493-11ea9952cfb3',
    'MX-Client-ID' => 'c3d38602-3a95-401f-9116-8fcedfa87dfd',
]);

$response = curl_exec($ch);

curl_close($ch);

Upvotes: 0

Obenland
Obenland

Reputation: 866

Google is your friend: There is a PHP-plugin which offers an API to use curl: https://secure.php.net/manual/de/book.curl.php

And you can use a class by pyromus and extend it to your needs: https://secure.php.net/manual/de/book.curl.php#86391

Upvotes: 1

Related Questions