chriskacerguis / codeigniter-restserver

A fully RESTful server implementation for CodeIgniter using one library, one config file and one controller.
MIT License
4.89k stars 2.86k forks source link

Got error after a Get service is completed #1144

Closed vladimirt2000 closed 2 years ago

vladimirt2000 commented 2 years ago

Describe the bug Im working a lot with your library, and didnt get errors until now. I have a GET service to send a Whatsapp message. The code works fine and finish without problems, but looking at the logs, I receive the error:

ERROR - 2022-08-11 13:52:23 --> Severity: Notice --> ob_end_flush(): failed to delete and f lush buffer. No buffer to delete or flush /opt/bitnami/projects/api/application/libraries/R estController.php 699

To Reproduce Here's the code Im using for the service:

public function send_whatsapp_image_get() { $template = $this->get('template'); $imagen = $this->get('imagen'); $parametros = $this->get('parametros'); $celular = $this->get('celular'); $auth = "XXXXXXXXXXXXX"; $url = "https://graph.facebook.com/v13.0/XXXXXXXXXXX/messages"; $components = array(); $parametros_header = array(); $parametros_header[] = array( "type" => "image", "image" => array( "link" => $imagen ) ); $components[] = array( "type" => "header", "parameters" => $parametros_header ); $components[] = array( "type" => "body", "parameters" => $parametros ); $request = array( "messaging_product" => "whatsapp", "to" => $celular, "type" => "template", "template" => array( "name" => $template, "language" => array( "code" => "es" ), "components" => $components ) ); $data_string = json_encode($request); log_message('debug','Request Whatsapp Image: '.$data_string); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 25); curl_setopt($ch, CURLOPT_TIMEOUT, 30);

    $headers = array(
        'Content-Type:application/json',
        'Authorization: Bearer '. $auth 
    );
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    $result = curl_exec($ch);
    $resulta = json_decode($result, true, JSON_UNESCAPED_SLASHES);
    $resultj = json_encode($resulta);
    $info = curl_getinfo($ch);
    log_message('debug','Result Whatsapp Image: '.$resultj);
    if (array_key_exists('messaging_product', $resulta)) {
        $this->set_response([
            'status' => TRUE,
            'data' => $resulta
        ], RestController::HTTP_OK);
    } else {
        $this->set_response([
            'status' => FALSE,
            'message' => "Ocurrió un error en el envío del Whatsapp"
        ], RestController::HTTP_OK);
    }
}

Environment (please complete the following information):

github-actions[bot] commented 2 years ago

There has been no activity on this issue, so it will be closed.