Hey there, my fellow CCB API-ers!
Today, we’re going on yet another API adventure! Our quest in this tutorial?
To use MICR account and routing numbers to uncover a person’s profile from Church Community Builder (CCB) using PHP.
Sounds fancy, right? But don’t worry—I’ll guide you every step of the way. Let’s dive in!
Prepping the Development Playground
Before we start our journey, open your favorite text editor (yes, even Notepad counts) and create a new file called individual-profile-from-micr.php.
Make sure you’re all set with your reusable global variables and functions. These should live in a separate file (includes/config.php
) from previous tutorials.
If you’ve been following along, you’re already a pro at this. If not, then buckle up!
Add the following code to set the stage for retrieving the profile:
<?php
/**
* Retrieve an individual profile using MICR data
*/
// Load reusable configs and helper functions
include(“includes/config.php”);
// Declare the API service
$apiService = ‘individual_profile_from_micr’;
// Define the necessary parameters
$accountNumber = ‘222222444’; // MICR account number
$routingNumber = ‘123456789’; // MICR routing number
?>
Preparing the CCB API Call
Now, we can’t just barge into the CCB API—it’s polite to bring along the right key-value pairs. Use PHP’s array_filter
to ensure we only send valid data. Add this next:
<?php
$urlData = array_filter(array(
‘srv’ => “$apiService”, // Service name
‘account_number’ => “$accountNumber”, // Account number
‘routing_number’ => “$routingNumber” // Routing number
));
$rss = ccbDetails(‘get’, $urlData); // Make the API call and store the XML response
?>
Imagine this as sending a friendly text to CCB: “Hey, can I get some details about this MICR combo?”
Parsing the API Call Response
Once the API call has been made, CCB will respond with a response payload of XML goodness. To unpack this XML response payload, you’ll need to perform the following:
<?php
$nodes = $rss->xpath(‘//individuals/individual’); // Extract relevant XML data
// Display the response in your browser
print_r($nodes);
?>
This code uses XPath to point to the exact spot where the profile details live in the response. Then, it prints everything out so you can bask in your API glory. 🌟
Let’s Bring It All Together
It’s time to put everything together and see the magic happen. Your full code should now look like this:
<?PHP
/**
* get individual profile from MICR
*/
// contains reusable globals and functions
include(“includes/config.php”);
$apiService = ‘individual_profile_from_micr’; // CCB api service
// individual_profile_from_micr per CCB required parameters
// REQUIRED PARAMETERS
$accountNumber = ‘222222444’; // integer/string
$routingNumber = ‘123456789’; // integer/string
$urlData = array_filter( array(
‘srv’ => “$apiService”,
‘account_number’ => “$accountNumber”,
‘routing_number’ => “$routingNumber”
) );
$rss = ccbDetails(‘get’,$urlData); // transform to XML
$nodes = $rss->xpath(‘//individuals/individual’); // xpath for import online gifts
print_r($nodes);
/*
<?xml version=”1.0″ encoding=”UTF-8″?>
<ccb_api>
<request>
<parameters>
<argument value=”individual_profile_from_id” name=”srv”/>
<argument value=”48″ name=”individual_id”/>
</parameters>
</request>
<response>
<service>individual_profile_from_id</service>
<service_action>execute</service_action>
<availability>public</availability>
<individuals count=”1″>
<individual id=”48″>
<sync_id></sync_id>
<other_id></other_id>
<giving_number></giving_number>
<campus id=”1″>Church of Cucumbers</campus>
<family id=”36″>The Bob Family</family>
<family_image>https://cdn3.ccbchurch.com/preSTABLE/images/group-default.gif</family_image>
<family_position>Primary Contact</family_position>
<family_members/>
<first_name>Larry</first_name>
<last_name>Bob</last_name>
<middle_name></middle_name>
<legal_first_name></legal_first_name>
<full_name>Larry Bob</full_name>
<salutation></salutation>
<suffix></suffix>
<image>https://cdn3.ccbchurch.com/preSTABLE/images/profile-default.gif</image>
<email>tsebastian@churchcommunitybuilder.com</email>
<allergies></allergies>
<confirmed_no_allergies>false</confirmed_no_allergies>
<addresses>
<address type=”mailing”>
<street_address></street_address>
<city></city>
<state>CO</state>
<zip></zip>
<country code=””> </country>
<line_1></line_1>
<line_2>CO</line_2>
<latitude></latitude>
<longitude></longitude>
</address>
<address type=”home”>
<street_address></street_address>
<city></city>
<state></state>
<zip></zip>
<country code=””> </country>
<line_1></line_1>
<line_2></line_2>
</address>
<address type=”work”>
<street_address></street_address>
<city></city>
<state></state>
<zip></zip>
<country code=””> </country>
<line_1></line_1>
<line_2></line_2>
</address>
<address type=”other”>
<street_address></street_address>
<city></city>
<state></state>
<zip></zip>
<country code=””> </country>
<line_1></line_1>
<line_2></line_2>
</address>
</addresses>
<phones>
<phone type=”home”>(098) 765-4321</phone>
<phone type=”work”></phone>
<phone type=”mobile”></phone>
</phones>
<mobile_carrier id=”0″> </mobile_carrier>
<gender></gender>
<marital_status></marital_status>
<birthday></birthday>
<anniversary></anniversary>
<baptized>false</baptized>
<deceased></deceased>
<membership_type id=””> </membership_type>
<membership_date></membership_date>
<membership_end></membership_end>
<receive_email_from_church>true</receive_email_from_church>
<default_new_group_messages>Group Default</default_new_group_messages>
<default_new_group_comments>Group Default</default_new_group_comments>
<default_new_group_digest>Group Default</default_new_group_digest>
<default_new_group_sms>Never</default_new_group_sms>
<privacy_settings>
<profile_listed>true</profile_listed>
<mailing_address id=”2″>My Friends</mailing_address>
<home_address id=”2″>My Friends</home_address>
<home_phone id=”3″>My Friends and Group Members</home_phone>
<work_phone id=”2″>My Friends</work_phone>
<mobile_phone id=”2″>My Friends</mobile_phone>
<emergency_phone id=”2″>My Friends</emergency_phone>
<birthday id=”4″>Everyone</birthday>
<anniversary id=”4″>Everyone</anniversary>
<gender id=”4″>Everyone</gender>
<marital_status id=”2″>My Friends</marital_status>
<user_defined_fields id=”2″>My Friends</user_defined_fields>
<allergies id=”1″>Church Leadership</allergies>
</privacy_settings>
<active>true</active>
<creator id=”1″>Larry Cucumber</creator>
<modifier id=”1″>Larry Cucumber</modifier>
<created>2012-09-25 15:29:15</created>
<modified>2012-09-25 15:30:50</modified>
<user_defined_text_fields/>
<user_defined_date_fields/>
<user_defined_pulldown_fields/>
</individual>
</individuals>
</response>
</ccb_api>
*/
?>
Next, open this file in your browser, and voilà! You’ll see all the details of the individual linked to the MICR data. Their name, email, phone, and maybe even their favorite Bible verse (okay, not that last part, but still pretty cool).
And there you have it! 🎉 You’ve just leveled up your PHP and CCB API skills while using MICR data to retrieve individual profiles like a pro.
Until next time, keep coding, keep dreaming, and keep the faith. 🙌
Pro Tips for Next-Level Awesomeness
- Error Handling: Always check for API errors and handle them gracefully. For example, what if the MICR data doesn’t match anyone?
- Privacy First: Don’t share sensitive MICR details with unauthorized folks (duh, right?).
- Keep Learning: Dive into CCB’s Public Web API Documentation to explore other cool services.