简体   繁体   中英

I'm trying to use curl with php but getting this error:Could not resolve host: Bearer

I'm trying to make a request using curl with php, but I'm getting the following error. Could I be using curl wrong? I generate $jwt on top lines

exec("curl -v -H 'Authorization: Bearer $jwt' \"https://api.storekit.itunes.apple.com/inApps/v1/refund/lookup/1234\"")

Could not resolve host: Bearer

This is how I can use it on this site apple

You can use curl like this

<?php
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.storekit.itunes.apple.com/inApps/v1/subscriptions/{original_transaction_id}');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');


$headers = array();
$headers[] = 'Authorization: Bearer '. $jwt;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
var_dump($result);
curl_close($ch);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM