Home Forums Newsletter Plugin Support newsletter subscription by http request or curl

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #26129
    carlo.cocco
    Participant

    Hi,
    I’m trying to submit a newsletter subscription request using the querystring “http://mysite/?na=s&ne=myemail@mydomain.com” making a GET request in PHP using the Requests library provided by WordPress, just like that code snippet:

    
    <?php
       $current_site = get_site_url();
       $my_email = "myemail@mydomain.com";
    
       $subscription_url = $current_site . "/?na=s";
       $newsletter_subscription_url = $subscription_url . "&ne=" . $my_email;
       
       Requests::register_autoloader();
       $response = Requests::get($newsletter_subscription_url); 
    ?>
    

    When I use the link in my browser, the subscription works well with success, but using a GET request from PHP or a curl command in a shell like “curl http://mysite/?na=s&ne=myemail@mydomain.com&#8221; I can’t subscribe.
    Where is my error?
    Is it possible to subscribe in that way or the plugin doesn’t permit to do that?
    Is there another way to do the same thing, using the plugin provided functions, and, if yes, can I have an example and a code snippet to do the subscription operation?
    Than you in advanced.

    Best regards,
    Carlo Cocco

    #26216
    Stefano
    Keymaster

    You should disable the antibot option in the subscription config panel to make such a request.

    Stefano.

    #26410
    carlo.cocco
    Participant

    Thank you Stefano,
    with WordPress provided Request library it works now.
    I can’t do the same with curl, but it’s not important.
    Best Regards,
    Carlo Cocco

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.