phpemailgithubcontextio

ContextIO API not working


Hi I am using contextIO api for fetch emails.I got a code from GitHub ,but it shows some errors.I am using this code ,

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'];
    }
}

But it shows a n error

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

Is it need a seperate gmail authentication? anyone please help me


Solution

  • All of the functions in the ContextIO library return a ContextIOResponse object, or false if the API returns an http error code. Check for if($r !== false) before you call getData() on $r and you should be good to go!

    (Note: I work on the context.io team and am currently the primary developer on the PHP libraries.)