Connect to API via PHP Curl

My request looks like this.

$config = array(
'url' => 'https://eu1.psb.fsapi.com/mp/v1/authentication/login',
'key' => 'myKey'
);
$data = array(
'username' => 'myUsername',
'password' => 'myPassword'
);
$headers = array(
'Content-Type: application/x-www-form-urlencoded',
'X-API-Key: '.$config['key']
);
/*list of curl options*/
$options = array(
CURLOPT_URL => $config['url'],
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => $headers,
);
/*curl handler*/
$ch = curl_init();
/*set options*/
curl_setopt_array($ch, $options);
/*excute*/
$result = curl_exec($ch);

For some reason i get this:
{"errors":[{"code":3030,"message":"login.error.badCredentials","lockDuration":1800000,"maxFailedLogins":5}]}

Comments

  • robin_jerome
    robin_jerome W/ Alumni Posts: 2 W/ Former Staff

    Hi,

     

    Can you share the complete response including transactionId?

     

    Regards,

    Robin

  • PavlinPetrov
    PavlinPetrov W/ Alumni Posts: 4 Security Scout
    Hi,

    This is all I get in my browser, when I run my php code. I'm using localhost if that helps. After the execution i close the curl handler and echo the result.

    How can i check the transaction id?
  • PavlinPetrov
    PavlinPetrov W/ Alumni Posts: 4 Security Scout

    Hi, 

    Here is what we get as response including headers:

     

     HTTP/1.1 401 Unauthorized Access-Control-Allow-Headers: Content-Type, Authorization, Content-Length, X-Requested-With, Current-Password, X-Api-Key, If-None-Match

    Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS

    Access-Control-Allow-Origin: *

    Access-Control-Expose-Headers: Location

    Access-Control-Max-Age: 600 cache-control: no-cache,no-store

    Content-Type: application/json; charset=utf-8

    Date: Tue, 19 Sep 2017 11:53:49 GMT

    ETag: W/"6c-0Anr2S6GsVfmq5bMK1OfHw"

    X-TX: c40aba9df13048cc8bf785a4cb281f2a

    Content-Length: 108

    Connection: keep-alive

     

    {"errors":[{"code":3030,"message":"login.error.badCredentials","lockDuration":1800000,"maxFailedLogins":5}]}

     

     

    That's all we get as response!

     

    BR,

    Dobri

  • PavlinPetrov
    PavlinPetrov W/ Alumni Posts: 4 Security Scout
    Thank you! Your code resolved the problem
This discussion has been closed.