2016-01-25 32 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); 

然後$結果應包含您正在查找的用戶信息。