• File: JavaCall.php
  • Full Path: /var/www/imaliapi/app/Classes/JavaCall.php
  • Date Modified: 04/15/2024 8:53 PM
  • File size: 984 bytes
  • MIME-type: text/x-php
  • Charset: utf-8
<?php


namespace App\Classes;
use Illuminate\Http\Request;


class JavaCall
{
    public function rechargeMpesa(Request $request){

        return $request->all();
       $curl = curl_init();
    //    curl_setopt($curl, CURLOPT_URL, 'http://localhost:8080/recharge');
       curl_setopt($curl, CURLOPT_URL, 'http://imalimoz.herokuapp.com/api/users');
       curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    //    curl_setopt($curl, CURLOPT_POST, true);
       curl_setopt($curl, CURLOPT_HTTPHEADER, ['Content-type: application/json']);
       curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
       curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

       $result = curl_exec($curl);
       $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
       $error = curl_error($curl);

       if($error) {
         echo "Curl Error: ".$error;
       }else{
        header('content-type: application/json');
        print_r($result);
       }
    }
}