I am trying to connect to the Bitpanda website using the php curl to retrieve my crypto assets.
Unfortunately it doesn't work, I'm adding a Powershell script that works, I hope someone can translate it into php...
I get the following error message:
{"errors":[{"status":401,"code":"unauthorized","title":"Credentials\/Access token wrong"}]}
Here is the example from Bitpanda:
curl -X GET "https://api.bitpanda.com/v1/trades" \
-H "X-API-KEY: string"
If the solution is in javascript, that would be enough for me :)
Thanks in advance
php don´t work:
$service_url = "https://api.bitpanda.com/v1/trades";
$curl_session = curl_init($service_url);
curl_setopt($curl_session, CURLOPT_USERPWD, $apiKey);
curl_setopt($curl_session, CURLOPT_HTTPHEADER, ['content-type: application/json']);
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl_session);
curl_close($curl_session);
echo $result;
powershell works:
$key = "APIKEY"
$trades = Invoke-WebRequest -Uri "https://api.bitpanda.com/v1/trades" -Headers @{"X-API-KEY" = $key} -UseBasicParsing
$tdata = $trades.Content | ConvertFrom-Json
$tdata.data.attributes | Out-GridView
Try this:
$header = array('X-API-KEY' => 'string');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.bitpanda.com/v1/trades');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,$header );
$response = curl_exec($ch);