0

I have been trying to use this paystack api

curl "https://api.paystack.co/bank" \
-H "Authorization: Bearer SECRET_KEY" 
-X GET

but don't know how to go about using using curl which am not really familiar with.

I have tried working my way around it but i get stuck all the time.

defined('BASEPATH') OR exit('No direct script access allowed');

class Bank_details extends CI_Controller {

    public function index()
    {
        $url = "https://api.paystack.co/bank";
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt(
          $ch, CURLOPT_HTTPHEADER, [
            'Authorization: Bearer SECRET_KEY']
        );
        $request = curl_exec($ch);
        curl_close($ch);
        var_dump(json_decode($request));
    }

}

with these lines, i am displayed with a message like so:

C:\wamp64\www\main_dir\application\controllers\Bank_details.php:22:null
courage
  • 115
  • 3
  • 20

1 Answers1

0

I think you missed providing JSON content type

curl_setopt($ch, CURLOPT_HTTPHEADER,
     array('Content-Type:application/json',)
  );
shivanisdev
  • 687
  • 6
  • 16