Get answers quicker by searching

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Added some API functionality
  • Vote Up0Vote Down jpvdpoeljpvdpoel
    Posts: 2Sendy user

    Hello,

    Because the editor currently does not support templating and we had the need for some of our clients to have this functionality we integrated Sendy in our used CMS system by extending the API. Since I saw some people with the same problem I decided to share our solution here. Our solution adds the following functionality to the Sendy API:

    • Create a campaign for a given user (Brand)
    • List all campaigns for a given user (Brand)

    Installation instructions:

    1. Download the installation package here: http://bit.ly/Wwc79i
    2. Unpack the .zip in the following folder: /path_to_your_sendy_installation/api/ (The api folder should now have a subfolder called /campaigns)
    3. Read documentation which is included in the zip: SendyCampaignsAPI.pdf

    This is not a complete and final solution. But for our clients this works great for now. They can create the newsletters in their usual CMS. Push to Sendy with the click of a button, and only need to assign a list and send it afterwards.

    Below is the API documentation


    Create campaign

    This method allows you to create a campaign for a specific user (Brand).

    URL
    http://your_sendy_installation/api/campaigns/create-campaign.php

    PARAMETERS (POST)
    api_key your API key, available in Settings.
    user_name login e-mail address of the brand
    subject campaign subject
    from_name name of the sender
    plain_text content of the mail, in plain text. Optional
    html_text content of the mail, in HTML. Optional

    RESPONSE (Plain text)
    Success: true
    Error: No data passed
    Error: API key not passed
    Error: Invalid API key
    Error: Username not passed
    Error: Invalid username
    Error: No subject given
    Error: No from name given


    List campaigns

    This method gets a list of campaigns for a specific user (Brand).

    URL
    http://your_sendy_installation/api/campaigns/list-campaigns.php

    PARAMETERS (POST)
    api_key your API key, available in Settings.
    user_name login e-mail address of the brand

    RESPONSE (Plain text)
    Success: You’ll get a list of campaigns, comma seperated
    Error: No data passed
    Error: API key not passed
    Error: Invalid API key
    Error: Username not passed
    Error: Invalid username


    Download the installation package here: http://bit.ly/Wwc79i

  • 8 Comments
  • Vote Up0Vote Down BenBen
    Posts: 3,484Sendy support

    Thanks a lot for your effort @jpvdpoel. I'll take a look at it soon.

  • Vote Up0Vote Down jpvdpoeljpvdpoel
    Posts: 2Sendy user

    One problem I encountered was that only 1 API key is currently available. I noticed the field exists for other users as well (Brands) but I was unable to generate a key unique for a Brand.

    If that would be possible an extra security check can be made based on the "user_name"-"api_key" combination, making it more secure.

  • Vote Up0Vote Down timbjamestimbjames
    Posts: 2Sendy user

    There seems to be a bug in the system in which the main account email, which is associated with the intallation, and a branch email are the same. The mysql query finds the first record which does not have an app and will return the error "Invalid username"

    I have added a fix which checks to see if the "app is not null"

  • Vote Up0Vote Down timbjamestimbjames
    Posts: 2Sendy user

    Another bug I have found is that when creating complex campaign html, there is a mysql error. I have added some code which is similar to how the save-campaign.php handles the inputs.

    $subject = addslashes($_POST['subject']);
    $plain_text = addslashes($_POST['plain_text']);
    $html_text = stripslashes($_POST['html_text']);
    
    $html_text = addslashes($html_text);
    

    This seems to work.

  • This is the exact functionality for the API that we have been looking for!

    jpvdpoel - thanks so much for sharing your solution. (I know this an old thread)

    Ben - is it likely that the Create/List campaign methods will ever be implemented in an official sendy release? It would make Sendy a whole lot more useful for us if it did this out of the box!

    Thanks

  • +1 Would be great to see this api functionality added to an official Sendy release.

  • Vote Up0Vote Down oshaosha
    Posts: 14Sendy user

    Hello @jpvdpoel,

    I saw this good post of yours and have one question: https://sendy.co/forum/discussion/768/added-some-api-functionality/p1

    I want to clarify if it does what I believe it does.

    1) A visitor subscribes to a list #1. 2) Through the autoresponder campaign he gets an opportunity to get a freebie but he needs to subscribe again. He does that and he gets to list #2. 3) If the subscriber wants to unsubscribe to list #1, or list #2 or both he will have a option to see all list he subscribed to.

    P.S. At the moment there is only unsubscribe from all list or one (must be configured at the admin level).

  • Vote Up0Vote Down maiacmaiac
    Posts: 3Sendy user

    Is there an updated link as the one in the original post does not currently work. Thanks and regards.