⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Issues regarding callback function in grocery curd



ondigit

ondigit
  • profile picture
  • Member

Posted 30 October 2018 - 15:03 PM

I am having a issue while passing data to view from controller.

I want pass the data after inserting record to another view for send notifications through api, this is my code refrerd from

 

/topic/324-workaround-redirect-to-the-list-after-insertupdate-without-changing-the-core-functionality-of-gc/page-2

               $crud->set_lang_string('insert_success_message',
            'Your data has been successfully stored into the database.<br/>Please wait while you are redirecting to the list page.
            <script type="text/javascript">
            window.location = "'.site_url('admin/notify/').'";
            </script>
            <div style="display:none">
            '

after notify in site url i want to pass the last insert id as well the form's data to my view to send notification.Please explain me what is wrong in this?

 

my notification file is:i want the passed data in this below function Please explain:

 

function sendMessage(){

    $content = array(
        "en" => 'Due to weather ALL Police Athletic League Centers will be closed on Wednesday.'
        );
        
    
     $content = array(
        "en" => "$notification_title"
        );

    $fields = array(
        'app_id' => "836c1f4c-a502-4d0a-8c1a-d056f73fa9ff",
        'included_segments' => array('All'),
        'data' => array("foo" => "bar"),
        'large_icon' =>"https://palnyc2008.thankyou4caring.org/image/_2015/layout/logoPAL.png",
        'large_icon' =>"https://palnyc2008.thankyou4caring.org/image/_2015/layout/logoPAL.png",
        'big_picture' =>"http://palnycapp.com/not.jpg",  
        'contents' => $content
    );

    $fields = json_encode($fields);
print("\nJSON sent:\n");
print($fields);

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications");
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8',
                                               'Authorization: Basic YzJiY2IyZjEtNjJkNC00MjhlLTg2YmItYjUwOGNhZTBjNzJk'));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);    

    $response = curl_exec($ch);
    curl_close($ch);

    return $response;
}