0
我想集成Google Analytics和Marchex(呼叫跟蹤系統)Call Analytics API來提取具有轉化率和類似內容的自定義報告。我對面向對象編程的世界非常非常陌生,並且認爲我需要一些指導才能實現這一目標。在我繼續前進之前,我想對構造函數進行一些批評。我是做對了還是什麼?將2個API集成到1個php類(OOP新手)
<?php
require_once("gapi.class.php");
require_once("xmlrpc.inc");
class garchex
{
private $marchex_credentials = array(),
$ga_credentials = array();
private $marchex_account, $ga_account;
public function __construct($marchex_credentials,$ga_credentials) {
assert(is_array($marchex_credentials));
assert(is_array($ga_credentials));
//setup marchex stuff
$this->marchex_credentials = $marchex_credentials;
$this->marchex_account = new xmlrpc_client("/api/xmlrpc/1", "api.voicestar.com");
$this->marchex_account->SetCredentials($marchex_credentials[0],$marchex_credentials[1]);
//google analytics stuff
$this->ga_credentials = $ga_credentials;
$this->ga_account = new gapi($ga_credentials[0],$ga_credentials[1]);
} // __construct
} // class garchex
?>
你的意圖是同時使用一個或其他,或兩者? – meagar 2011-02-17 22:23:18
這不是真正的問題。也許發佈在程序員或代碼審查。 – Phil 2011-02-17 22:24:29