示例#1
0
function handleDefault($hb)
{
    $token = isset($_COOKIE['token']) ? $_COOKIE['token'] : null;
    $params = ['siil_url' => $_ENV['SIIL_URL'], 'site_id' => $_ENV['SIIL_SITE_ID'], 'authed' => false];
    if (!is_null($token)) {
        $tokenInfo = makeAPIRequest($token);
        if (!is_null($tokenInfo) && verify($tokenInfo)) {
            $params['authed'] = true;
            $params['first_name'] = $tokenInfo['user']['first_name'];
            $params['last_name'] = $tokenInfo['user']['last_name'];
            $dt = DateTime::createFromFormat(DateTime::RFC3339, $tokenInfo['expires_at']);
            $now = new DateTime("now");
            $params['expiry'] = $dt->diff($now)->format("%h hour(s) %I minutes %S seconds");
            $params['token'] = $tokenInfo['token'];
            $params['code'] = $tokenInfo['user']['code'];
        } else {
            setcookie("token", "", time() - 3600);
        }
    }
    echo $hb->render('index', $params);
}
 function followATweety($screen_name)
 {
     $consumer = new Zend_Oauth_Consumer($this->config);
     return makeAPIRequest('http://api.twitter.com/1/friendships/create.json', array('screen_name' => $screen_name));
 }