Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 04-16-2011, 10:11 PM
brandondrury brandondrury is offline
 
Join Date: Oct 2005
Posts: 136
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Office Auto Pilot Integration

I'm quite rusty on my php programming so there are probably 10,000 things that could be improved. This works on my local server, so it is what it is. I'm too busy to upkeep this, but I figured I'd post it here as the community has been so helpful to me in the past. Use at your own risk.

I'm awaiting an email from the API support at Office Auto Pilot (it's a weekend, usually they are INSANELY fast to respond). The one flaw I can see in this so far is when a user is added to these sequences, they bypass the double opt-in, which I definitely prefer. So I'm guessing more info needs to be added to the code to specify to Office Auto Pilot to send out a confirmation email.

I'm using vb4.1.3.
Create a new plugin with a hook of register_addmember_process and paste this code.

Be sure to enter your API app and key info and make sure the fields are appropriate.

PHP Code:
<?php
// This will go in the Office Auto Pilot plugin

// Steal username from the vbulletin variables    
$oap_user $vbulletin->GPC['username'];

// Steal email address from the vbulletin variables
$oap_email $vbulletin->GPC['email'];

// Determine Sequences

/*  This code will determine which sequences from Office Auto Pilot to use.  You can see that I have #1 and #4 here depending on what the user ultimately wants.  I used the custom fields thingy in the Admincp which, for me, ended up being field 5 and field 7.  I used phpmyadmin to determine the field names in the userfield table.  These field names pop up throughout this little plugin so make sure they are all set accordingly.*/


if ($vbulletin->GPC['userfield']['field5'] ==2) {$oap_SU=1;} 
if (
$vbulletin->GPC['userfield']['field7'] ==2) {$oap_news=1;} 
if (
$oap_news and $oap_SU) { $oap_sequence "*/*1*/*4*/*";}
if (
$oap_news and !$oap_SU) { $oap_sequence "*/*4*/*";}
if (!
$oap_news and $oap_SU) {$oap_sequence "*/*1*/*";}

// Subscribe 'em
// I decided that I'd just use the first name field in Office Auto Pilot to hold the vbulletin username.

if ($oap_sequence)
{    
$data = <<<STRING
<contact>
<Group_Tag name="Contact Information">
<field name="First Name">
$oap_user</field>
<field name="E-Mail">
$oap_email</field>
</Group_Tag>
<Group_Tag name="Sequences and Tags">
<field name="Sequences">
$oap_sequence</field>
<field name="Contact Tags"/>
</Group_Tag>
</contact>
STRING;
  
$data urlencode(urlencode($data));

$appid "";  // Your appid goes here.
$key "";  // Your key goes here.


$reqType"add";
$postargs "appid=".$appid."&key=".$key."&return_id=1&reqType=".$reqType"&data=" $data;
$request "http://api.moon-ray.com/cdata.php";

$session curl_init($request);
curl_setopt ($sessionCURLOPT_POSTtrue);
curl_setopt ($sessionCURLOPT_POSTFIELDS$postargs);
curl_setopt($sessionCURLOPT_HEADERfalse);
curl_setopt($sessionCURLOPT_RETURNTRANSFERtrue);
$response curl_exec($session);
curl_close($session);
header("Content-Type: text/xml");
//echo $response;

//SNAG RETURN ID FROM OAP
$xml = new SimpleXMLElement($response);
$oap_return_id $xml->contact->attributes()->id;
 

// UPDATE FIELD6 OAP IN DATABASE
// In the event that I ever need to edit their email address, username, etc in Office Auto Pilot, I pulled the id variable out of Office Auto Pilot and stored it in this userfield.
$fieldvariable = array('field6' => $oap_return_id);
$userdata->set_userfields($fieldvariabletrue'admin');
}
    
/// End of OAP plugin
?>
I hope this helps.
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 11:59 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04435 seconds
  • Memory Usage 2,228KB
  • 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)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)showthread_list
  • (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_threadedmode.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_threaded
  • showthread_threaded_construct_link
  • 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