2014-10-30 47 views
0

嗨,我使用contextIO API來獲取emails.I了從GitHub代碼,但它顯示了一些errors.I正在使用此代碼,ContextIO API不工作

include_once("class.contextio.php"); 

// see https://console.context.io/#settings to get your consumer key and consumer secret. 
$contextIO = new ContextIO('asssasas','sdsd1111sdsdsd'); 
$accountId = null; 

// list your accounts 
$r = $contextIO->listAccounts();//print_r($r); 
foreach ($r->getData() as $account) { 
    echo $account['id'] . "\t" . join(", ", $account['email_addresses']) . "\n"; 
    if (is_null($accountId)) { 
     $accountId = $account['id']; 
    } 
} 

但它顯示了一個錯誤

Fatal error: Call to a member function getData() on a non-object 

是否需要單獨的Gmail身份驗證?任何人請幫助我

回答

3

如果API返回http錯誤代碼,則ContextIO庫中的所有函數均返回ContextIOResponse對象,或返回false。在撥打getData()$r之前,請檢查if($r !== false),您應該很好!

(注意:我在context.io團隊工作,目前是PHP庫的主要開發人員。)