Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 05-13-2011, 08:01 AM
jGas jGas is offline
 
Join Date: May 2007
Posts: 172
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Mailchimp plugin for 3.8.7: What do I need to modify?

Hi, this code is working great on the site where I found it, http://www.bestrecipes.com.au/site/mailchimp.html, that is running 3.8.3 but not on my board that is 3.8.7.

This is the plugin code:



Code:
require_once 'mailchimp/MCAPI.class.php'; // location of API file, relative to
forum root directory
$apikey= 'myapikey-us2'; // your API key
$listId = '3af3706004321'; // the list ID

// Connect to the MailChimp server
$api = new MCAPI($apikey);

if ($api->errorCode!=''){

// an error occurred while logging in, errors commented in HTML
echo "<!-- code:".$api->errorCode."-->";
echo "<!-- msg :".$api->errorMessage."-->";
die();
}

// get current user details
$my_email=($vbulletin->userinfo['email']);

// profile fields are best set up as single-selection radio buttons,
// use multiple profile fields for interest groups and mail format

// vBulletin profile field options:
// use Yes/No options (use HTML/Text for mail format)
// Set default: Yes
// Field Required: No but display at registration
// Field Editable by User: Only at registration
// Handle unsubscribes and profile updating via links in mailings, or another
API plugin

$news1=($vbulletin->userinfo['field12']); // add custom profile field number
for interest group 1
// $news2=($vbulletin->userinfo['field14']); // add custom profile field
number for interest group 2
// $news3=($vbulletin->userinfo['field15']); // add custom profile field
number for interest group 3

$newsformat=strtolower(($vbulletin->userinfo['field13'])); // profile field
number for mail format, html or text

// add interest group names, note trailing commas in all but last one - a
quick hack but it works!

if ($news1=='Yes') {
$interests='Interest group name here,';  // escape apostrophes in name with a
backslash i.e. What\'s On
}

if ($news2=='Yes') {
$interests.='Interest group name here,';
}

if ($news3=='Yes') {
$interests.='Interest group name here';
}

$merge_vars = array('INTERESTS'=>$interests);
// only send request if subscribed to at least 1 newsletter
if ($news1=='Yes' || $news2=='Yes' || $news3=='Yes') {
$retval = $api->listSubscribe( $listId, $my_email, $merge_vars, $newsformat
);
}

if (!$retval){
        // return error codes, commented in HTML
echo "<!--Newsletter failed!-->";
echo "<!--\tCode=".$api->errorCode."-->";
echo "<!--\tMsg=".$api->errorMessage."-->";
// email backup for API failures, multiple subscribes etc.
$to      = 'info@musicadigitale.net';
$subject = 'Newsletter API failed';
$message = "The following member details were not subscribed by the API:\n";
$message .= "Email: $my_email\n";
$message .= "Interest groups: $interests\n";
$message .= "Mail format: $newsformat\n";
$message .= "Error message: " . $api->errorMessage . "";
$headers = "From: MailChimp API <adminemail@domain.com>\n";
$headers .= "Reply-To: adminemail@domain.com\n";
$headers .= "X-Mailer: Your forum name\n";
mail($to, $subject, $message, $headers);
} else {
    echo "<!--Newsletter subscribed ok-->";
}
Many thanks for your time
Reply With Quote
  #2  
Old 05-13-2011, 01:32 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In the line:

Code:
$news1=($vbulletin->userinfo['field12']);

Did you change the field to match your actual custom profile field number?

Also if those are really your api key and list number I'm guessing you shouldn't be posting them (and if they aren't, did you enter your values there when you tried it?).

You didn't say what actually happens on your site.
Reply With Quote
  #3  
Old 05-13-2011, 02:15 PM
jGas jGas is offline
 
Join Date: May 2007
Posts: 172
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for your reply!
Don't worry, I removed the correct keys and list number before posting here
Also the fields are correct.

This plugin works during registration of a new user.
When I try to register, the user is correctly registered but
1) it's not added to the mailing list
2) I get a white page instead of "you need to confirm your account, check your email" page...
That's strange!
Reply With Quote
  #4  
Old 05-13-2011, 02:33 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry, but occasionally someone will copy a block of code and have no idea about how it shoud be edited

Anyway, I'm probably going to say a couple more obvious things, but: if you see a white page I'd guess that maybe it's hitting that die(). Did you "view source" of the blank page to see if those html comments are there?

Also maybe make sure that the MCAPI.class.php file is in the right place, but I think you'd see an error message if is wasn't.
Reply With Quote
  #5  
Old 05-13-2011, 03:05 PM
jGas jGas is offline
 
Join Date: May 2007
Posts: 172
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No problem
Well I can't view the source because it isn't a real blank page, it's a "Content Encoding Error" page (firefox reports this error)

MCAPI.class.php file is in the right place
Reply With Quote
  #6  
Old 05-13-2011, 03:15 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm...maybe you could comment out the die and put the code after that block in an else and see what that does.
Reply With Quote
  #7  
Old 05-13-2011, 03:25 PM
jGas jGas is offline
 
Join Date: May 2007
Posts: 172
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If I comment the "die" I get the same message as before... maybe because it isn't an api error...?
Reply With Quote
  #8  
Old 05-13-2011, 03:28 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, looks like my guess was wrong.
Reply With Quote
  #9  
Old 05-13-2011, 03:36 PM
jGas jGas is offline
 
Join Date: May 2007
Posts: 172
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The problem is, that on a vbulletin 3.8.3 it IS working...
Reply With Quote
Reply

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:27 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03826 seconds
  • Memory Usage 2,231KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete