Frequently asked questions

Can I integrate Akeeba Subscriptions for Joomla to MASS

If you have installed Akeeba Subscriptions Component on your Joomla Website you may install our Web Service PHP script. This will allow MASS for Windows to extract the Member and Payment details from the Web site. This will upgrade any existing members and automatically create new members in MASS with the new details.

Use this Script on your Web site:-

<?php

/* Server Script
* webServiceAkeebaSubs.php 
* Create a Web service to present all the new Valid subscription paid for.
* To see values on the screen run: testWebServerAkeebaSubs.php, if installed
*/

//The following will convert the data into SOAP and allow for WSDL
require_once("nusoap/nusoap.php"); //This will need to be installed - Free component.

$server = new soap_server();

$server->configureWSDL('enrolserver', 'http://xxxx.org.au/webServiceAkeebaSubs');

$server->wsdl->schemaTargetNamespace = 'http://xxxx.org.au/webServiceAkeebaSubs';
$server->register('getEnrolStatus', array('value' => 'xsd:string'), array('return' => 'xsd:string'), 'http://xxxx.org.au/webServiceAkeebaSubs', 'http://xxxx.org.au/webServiceAkeebaSubs#getEnrolStatus');

/* connect to the db */
//require_once("includes/inc_connect.php");
$dbUsername = "your_name";
$dbPassword = "your_password";
$dbHostname = "localhost"; //This is the database server
$dbDatabase = "xxxxxx_joomla"; //This is the database
$dbLink = mysql_connect($dbHostname, $dbUsername, $dbPassword) or die("Unable to connect to MySQL");
$dbselected = mysql_select_db($dbDatabase, $dbLink) or die("Could not select database");


/* grab the posts from the db */

function getEnrolStatus() {

$returnString = "";/* soak in the passed variable or set our own */

$format = strtolower($_GET['format']) == 'json' ? 'json' : 'xml'; //xml is the default

$today = Date("Y-m-d", strtotime("-60 days", strtotime(Date("Y-m-d")))); // Go back -60 days, so we do not miss any

$sqlquery = "SELECT cvh6c_akeebasubs_subscriptions.user_id,
cvh6c_akeebasubs_subscriptions.akeebasubs_invoice_id,
cvh6c_akeebasubs_subscriptions.akeebasubs_level_id,
cvh6c_akeebasubs_subscriptions.akeebasubs_subscription_id,
cvh6c_akeebasubs_subscriptions.created_on, 
cvh6c_akeebasubs_subscriptions.enabled,
cvh6c_akeebasubs_subscriptions.gross_amount,
cvh6c_akeebasubs_subscriptions.net_amount,
cvh6c_akeebasubs_subscriptions.publish_down, 
cvh6c_akeebasubs_subscriptions.publish_up, 
cvh6c_users.name,
cvh6c_users.username,
cvh6c_users.email, 
cvh6c_akeebasubs_users.address1, 
cvh6c_akeebasubs_users.address2, 
cvh6c_akeebasubs_users.city, 
cvh6c_akeebasubs_users.state, 
cvh6c_akeebasubs_users.zip, 
cvh6c_akeebasubs_users.country,
cvh6c_akeebasubs_users.params, 
cvh6c_akeebasubs_users.occupation 
FROM cvh6c_akeebasubs_subscriptions
JOIN cvh6c_users on cvh6c_akeebasubs_subscriptions.user_id = cvh6c_users.id 
JOIN cvh6c_akeebasubs_users on cvh6c_akeebasubs_users.user_id = cvh6c_users.id 
WHERE created_on > '$today' AND enabled=1
ORDER BY created_on";

$result = mysql_query($sqlquery);

$posts = array();
if (mysql_num_rows($result)) {
    while ($post = mysql_fetch_assoc($result)) {
    $posts[] = array('post' => $post);
}
}

/* output in necessary format */
if ($format == 'json') {
//This should not happen, as not using json.
header('Content-type: application/json');
echo json_encode(array('posts' => $posts));
//$returnString.= "json_encode(array('posts'=>$posts))";
} else {
header('Content-type: text/xml');

$returnString = "<posts>";

foreach ($posts as $index => $post) {
if (is_array($post)) {
foreach ($post as $key => $value) {
$returnString.= "<$key>";
if (is_array($value)) {
foreach ($value as $tag => $val) {
if ($val != "") {
$val = htmlentities($val);
$returnString.= "<$tag>$val</$tag>";
} else {
$returnString.= "<$tag>0.00</$tag>";
}
}
}
$returnString.= "</$key>";
}
}
}

$returnString.= "</posts>";
}
return $returnString;
}

//getEnrolStatus(); //This will display the XML data after the Response stuff. This must be removed when going live.

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);

/* disconnect from the db */
mysql_close()
?>