View Single Post
  #7  
Old 04-03-2017, 12:58 AM
 
ajeetsingh ajeetsingh is offline
 

Member
  
Join Date: Dec 2016
Posts: 28
 

Default Re: Issue in Curl calling in xcart page

Hello qualiteam,


I am explaining step by step below: Please try to understand my problem.

1. At x-cart backend, I have create a page where n number of records are listed and there is a notify button for each record as shown in attachment.

2. I just want that when i click on the Notify Button i just want to show a notification in mozila firefox as like other eCommerce site send a notification for their new products or any other information when i subscribed their notification service.

3. So for that purpose on the click on that notification button i will call an ajax and the targer of that ajax is Notiftmplt and action is Notify.

4. Then Under the Notify function of that controller class Notiftemplt, i just call that finction sendPushMozila() which have the following code below:
PHP Code:
public function sendPushMozila($sub_ids){
        
$url 'https://updates.push.services.mozilla.com/wpush/v1/';
        
$headers = array(
          
'Content-Type: application/json',
          
'TTL: 600000'
        
);
        foreach (
$sub_ids as $key => $value) {
            
$final_url=$url.$value;
            
$ch curl_init();  
            
// Set the url, number of POST vars, POST data
            
curl_setopt($chCURLOPT_URL$final_url);
            
curl_setopt($chCURLOPT_POSTtrue);
            
curl_setopt($chCURLOPT_HTTPHEADER$headers);
            
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);

            
curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
            
/*curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));*/
            
$result curl_exec($ch);
            
//var_dump($result); die;
            
curl_close($ch);
        }
    } 

In the above code the $sub_ids is the subscription ids of more users.

IF any further clarification, Please let me know.
Attached Thumbnails
Click image for larger version

Name:	screenshot-ajeet.com-2017-04-03-14-28-10.png
Views:	354
Size:	59.7 KB
ID:	4884  
__________________
Ajeet Singh
Sr.Software Developer
Webkul Software Pvt. Ltd.
Reply With Quote