Back to Documentation Overview

login

public static login(string username, string password)

DEPRECATED: Log into the MailChimp API and return an API Key. There is no reason to call this in a real app, just hard code your API Key from this or http://admin.mailchimp.com/account/api/. By default the oldest one is returned. If you've never logged into the API before, this will create your first API Key.

Deprecated:
User a wrapper that supports our datacenters, or hard code your API Key and endpoint
Section:
Security Related
Parameters:
username Your MailChimp user name
password Your MailChimp password
Returns:
string   -  an API Key for your user account that will be passed into the rest of the API calls

Examples (2)

download example code

[1] xml-rpc_login.php

  1. <?php
  2. /**
  3. This Example shows how to Login using the XML-RPC service and do some
  4. basic error checking.
  5. Note that we are using the PEAR XML-RPC client and recommend others do as well.
  6. **/
  7. require_once 'XML/RPC2/Client.php';
  8. require_once 'inc/config.inc.php';
  9. try {
  10. $client = XML_RPC2_Client::create($apiUrl);
  11. $apikey = $client->login($username,$password);
  12.  
  13. echo "SUCCESS!\n";
  14. echo "Your API Key is :". $apikey."\n";
  15. } catch (XML_RPC2_FaultException $e){
  16. echo "ERROR!!!!\n";
  17. echo $e->getFaultCode()." : ".$e->getFaultString()."\n";
  18. }
  19. ?>
  20.  

[2] mcapi_login.php

  1. <?php
  2. /**
  3. This Example shows how to use the MCAPI.php class without actually ever needing
  4. the account Username & Password.
  5. **/
  6. require_once 'inc/MCAPI.class.php';
  7. require_once 'inc/config.inc'; //contains username & password
  8.  
  9. $api = new MCAPI($username, $password);
  10.  
  11. if ($api->errorCode){
  12. echo "Unable to login!\n";
  13. echo "code:".$api->errorCode."\n";
  14. echo "msg :".$api->errorMessage."\n";
  15. die();
  16. } else {
  17. echo "Success. Your API Key is:\n";
  18. echo "\t".$api->api_key."\n";
  19. }
  20.  
Add New Note User Contributed Notes for login
Jeff Boes : jeff -at- endpoint -dot- com
2009-11-09 14:43:34
Example Language: perl
 FYI, the Mail::Chimp::API Perl module (http://search.cpan.org/~dpirotte/Mail-Chimp-0.12/lib/Mail/Chimp/API.pm) supports only the username/password authentication at this time.