Answer the question
In order to leave comments, you need to log in
How to convert curl to PHP?
the goal is to get a token from api.easypay.ua, there is a working code that needs to be redone for php:
curl -X POST \
--header "Content-Type:
application/x-www-form-urlencoded" \
--header "Accept: application/json" \
--header "PartnerKey: easypay-v2" \
--header "locale: UA" \
--header "AppId: b826a751-0571-47c1-9709-dd639c364919" \
--header "PageId: bfe30747-ed11-4143-919b-ed2f91c65114" \
-d "client_id=easypay-v2&grant_type=password&username=user&password=pass" \
"https://api.easypay.ua/api/token"
$ch = curl_init();
curl_setopt($ch,
CURLOPT_URL, 'https://api.easypay.ua/api/token');
curl_setopt($ch,
CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "client_id=easypay-v2&grant_type=password&username=user&password=pass");
$headers = array();
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
$headers[] = 'Accept: application/json';
$headers[] = 'Partnerkey: easypay-v2';
$headers[] = 'Appid: b826a751-0571-47c1-9709-dd639c364919';
$headers[] = 'Locale: UA';
$headers[] = 'Pageid: bfe30747-ed11-4143-919b-ed2f91c65114';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question