Created
July 19, 2016 23:08
-
-
Save jwieder/278e33ec6953f4434bf8c7fa432590cb to your computer and use it in GitHub Desktop.
A simple PHP script that allows users that allows WHMCS users to retrieve Product Bundle details including Display Price, Description, et al. Responses output is JSON encoded. Tested in WHMCS v6.3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// HTTP USAGE: | |
// http://example.com/GetBundles.php?bid= | |
// BASH CLI EXAMPLE USAGE: | |
// export QUERY_STRING="bid=2" ; php -e -r 'parse_str($_SERVER["QUERY_STRING"], $_GET); include "GetBundles.php";' | |
$db_host = "mysql.databasehost.ext"; | |
$db_name = "mysqlDatabaseName"; | |
$db_user = "MysqlUsername"; | |
$db_pass = "MySq1p@Ssw0rd!"; | |
$BUNDLE = $_GET["bid"]; | |
$link = new PDO("mysql:host=$db_host;dbname=$db_name", $db_user, $db_pass); | |
$link->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
$link->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); | |
$link->quote($BUNDLE); | |
$stmt = $link->prepare("SELECT * FROM tblbundles WHERE id = :bid"); | |
$stmt->bindParam(':bid', $BUNDLE, PDO::PARAM_STR); | |
$stmt->execute(); | |
$dbRow = $stmt->fetchAll(PDO::FETCH_ASSOC); | |
echo json_encode($dbRow, JSON_UNESCAPED_UNICODE); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment