Jump to content

Search the Community

Showing results for tags 'api'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome
    • Announcements & News
    • New Arrivals
  • Web Development
    • Programming
    • Database Development
    • Server Administration
    • Hosting & Domains
    • Frameworks
  • Web Design
    • HTML & CSS
    • Graphics & Multimedia
  • Desktop Discussion
    • Linux Development
    • Windows Development
    • Mac/Apple Development
    • Hardware Discussion
  • Marketing & Business
    • Advertising, Marketing, Monetization & Social Media
    • Search Engine Optimization & Traffic Building
    • Buy, Sell or Trade
  • Prodjex Web Development Applications, Tools and Plugins
    • IP.Board Applications and Plugins
    • Web Tools
  • The Developer Dump
    • General Chat

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL







Found 1 result

  1. MailChimp allows you to create sign up forms with their builder, but they can be a pain to style and for some don’t allow enough customization. The following code is an example of how you can take advantage of the MailChimp API to subscribe new users. Doing this allows you to then create a custom sign up form and style it easily to match your own look and feel. This example assumes you’re only passing the First Name, Last Name, and email of a new subscriber. It’s easy enough to add additional fields, but this will get you started. First you’ll need to setup an API key in your MailChimp account, so login and navigate to Account -> Extras -> API Keys. Once you’ve clicked to create a new API key go ahead and copy the API key and place it in your code. Now you will need to find the list ID. This is not the ID of the list from the URL. You need to go to your lists and in the drop down select settings. Scroll all the way down and here you will find your list ID to replace in the code. You’re all set, now create your form matching the names from the following script and set your form action to “GET”. <?php /** * Created by PhpStorm. * User: Prodjex * Date: 1/31/2018 * Time: 9:04 AM */ //Grab Data Variables Passed From Form $data = [ 'email' => $_GET['email'], 'status' => 'subscribed', 'firstname' => $_GET['firstname'], 'lastname' => $_GET['lastname'] ]; syncMailchimp($data); function syncMailchimp($data) { $apiKey = 'Your API KEY'; $listID = 'Your List ID'; $memberID = md5(strtolower($data['email'])); $dataCenter = substr($apiKey, strpos($apiKey, '-') + 1); $url = 'https://' . $dataCenter . '.api.mailchimp.com/3.0/lists/' . $listID . '/members/' . $memberID; $json = json_encode([ 'email_address' => $data['email'], 'status' => $data['status'], // "subscribed","unsubscribed","cleaned","pending" 'merge_fields' => [ 'FNAME' => $data['firstname'], 'LNAME' => $data['lastname'] ] ]); $ch = curl_init($url); curl_setopt($ch, CURLOPT_USERPWD, 'user:' . $apiKey); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); $result = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return $httpCode; } View Blog Post
  • Create New...