Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Issue in Curl calling in xcart page

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 03-22-2017, 07:59 AM
 
ajeetsingh ajeetsingh is offline
 

Member
  
Join Date: Dec 2016
Posts: 28
 

Default Issue in Curl calling in xcart page

Hello,

I have an issue in calling the curl to send a notification message in admin area using code below:
PHP Code:
$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;
            
//echo $finCURLOPT_POSTCURLOPT_POSTCURLOPT_POSTCURLOPT_POSTCURLOPT_POSTCURLOPT_POSTal_url;
            
$ch curl_init();  
            
// Set the url, number of POST vars, POST data
            
curl_setopt($chCURLOPT_URL$final_url);
            
curl_setopt($ch, , true);
            
curl_setopt($chCURLOPT_HTTPHEADER$headers);
            
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);

            
curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
            
curl_close($ch); 
Here $sub_ids is the subscription is which i get from browser for a client.
Please anyone can suggest me that what is wrong.
__________________
Ajeet Singh
Sr.Software Developer
Webkul Software Pvt. Ltd.
Reply With Quote
  #2  
Old 03-23-2017, 10:58 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Issue in Curl calling in xcart page

Instead of a direct Curl call try to use the ready-made \XLite\Core\HTTP\Request class.
You can find examples of using this class in the source code.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #3  
Old 03-24-2017, 06:20 AM
 
ajeetsingh ajeetsingh is offline
 

Member
  
Join Date: Dec 2016
Posts: 28
 

Default Re: Issue in Curl calling in xcart page

Hello
qualiteam,

Actually i do not get any types of class that are using source code for \XLite\Core\HTTP\Request.

So please suggest me in right way that's way i will be able to solve mu issue.
__________________
Ajeet Singh
Sr.Software Developer
Webkul Software Pvt. Ltd.
Reply With Quote
  #4  
Old 03-31-2017, 12:02 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Issue in Curl calling in xcart page

Please check how the class is used in the source code:
https://github.com/xcart/xcart5/search?p=3&q=%5CXLite%5CCore%5CHTTP%5CRequest&type =&utf8=%E2%9C%93

For example, here:
https://github.com/xcart/xcart5/blob/cf1f28cec010ef7044cc8bbfe2fe39eac0e30196/src/classes/XLite/Module/CDe.../Core/AAPI.php
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #5  
Old 04-01-2017, 02:34 AM
 
ajeetsingh ajeetsingh is offline
 

Member
  
Join Date: Dec 2016
Posts: 28
 

Default Re: Issue in Curl calling in xcart page

Hello ,

I am not getting a wright solution for my problem. Again i am explaining my problem below:

I just want to call a notification message in a xcart backend page on clicking a button on that page for Mozila FireFox browser, And for that purpose i am using the curl request and the code for which i am using for the function is as 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 then one user.

So please help me.

Thanks in Advance.
__________________
Ajeet Singh
Sr.Software Developer
Webkul Software Pvt. Ltd.
Reply With Quote
  #6  
Old 04-02-2017, 10:50 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Issue in Curl calling in xcart page

I'm sorry, but I don't understand what the problem is.
Please describe in steps what you want to implement and explain which steps you have problems with.
Have you added the button already? Is the problem that you don't know how to call your sendPushMozila() function on the server when a user clicks that button in the browser? How and where did you added sendPushMozila() function?
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #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:	350
Size:	59.7 KB
ID:	4884  
__________________
Ajeet Singh
Sr.Software Developer
Webkul Software Pvt. Ltd.
Reply With Quote
  #8  
Old 04-04-2017, 12:50 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Issue in Curl calling in xcart page

You said "I have an issue in calling the curl to send a notification message".
What is the issue?

You explained what you do, but you didn't say what is not working in the code that you have implemented. Do you see an error message? Or what?

If it is the curl call that causes a issue, try to use the \XLite\Core\HTTP\Request class as I have suggested. You can find examples of how to use this class in the source code of X-Cart itself.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 01:32 AM.

   

 
X-Cart forums © 2001-2020