Hi i’m new at the codeigniter. I’m trying to intigrate some payment gateway to an site. I send my callback url to my provider as http://myurl.com/Callbacka and they declared. So,i trigger the send_post_request function call the url http://myurl.com/Callbacka/send_post_requestin browser but nothing happen.I can’t figure out what i’m missing..Thanks for any help.
<?php
class Callbacka extends controller {
function __construct() {
parent::controller();
$this->admin = $this->load->model("admin");
$this->user = $this->load->library("user");
$this->cookie = $this->load->library("cookie");
}
/*public function index($id) { //
$requestData = json_decode(file_get_contents('php://input'), true);
$responseDatas = json_decode($requestData, true);
echo $responseDatas;
}*/
public function send_post_request() {
// Data to be sent in the POST request
$post_data = array(
'sid' => '9980',
'key' => 'nSW45i395Sx2SP998XB6p410W7wX43tf8n6a6Y5slKkM1z2D0UyGxd5eh7ucJ_bAZ8j'
// Add any other data you need to send
);
// Initialize cURL session
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, 'https://api.serviceprovider.com/BankList/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
// Execute the cURL session
$response = curl_exec($ch);
// Close the cURL session
curl_close($ch);
//$responseData = json_decode($response, true);
//echo $responseData;
// Process the response as needed
// For example, you can pass the response to the callback function
$this->handle_callback($response);
}
// Callback function to handle the response from the other site
public function handle_callback($response) {
// Handle the response data received from the other site
// For example, you can echo the response
echo $response;
$this->db->query("UPDATE admin SET name = $response_data WHERE username = 'demone'");
// You can perform any necessary actions on the response from the other site
}
}
?>