2016-01-25 33 views
1

我试图检查用户是否登录并显示外部whmcs文件夹的名字。我正在使用Feed。我已经在feeds文件夹中创建了checkifloggedin.php。创建whmcs 6饲料来检查客户是否登录

<?php 
require("../init.php");  
if (isset($_SESSION['uid'])) { 

    /*i can get the the id of the user but i cannot display the first 
     name of the logged in user. tried several methods but i cannot 
     make it work.*/ 

    widgetoutput(); 
    } 
else { 
    widgetoutput('logged out'); 
} 

function widgetoutput($value) { 
    echo "document.write('".addslashes($value)."');"; 
    exit; 
} 

?> 

任何帮助,你们都会如此赞赏。

非常感谢。

回答

0

我认为你正在寻找使用WHMCS平台的内部API: http://docs.whmcs.com/API:Internal_API

在控件的代码,你会想使用这样的:

// Set Vars 
$command = 'getclientsdetails'; 
$values = array('clientid' => $_SESSION['uid'], 'responsetype' => 'json',); 
$adminuser = 'DemoAdmin'; 

// Call API 
$results = localAPI($command, $values, $adminuser); 
if ($results['result']!="success") { 
    echo "An Error Occurred: ".$results['result']; 
    exit; 
} 

$results = json_decode($results); 

然后$结果应包含您正在查找的用户信息。