function appnet_connect(&$a) { require_once 'addon/appnet/AppDotNet.php'; $clientId = get_config('appnet', 'clientid'); $clientSecret = get_config('appnet', 'clientsecret'); if ($clientId == "" or $clientSecret == "") { $clientId = get_pconfig(local_user(), 'appnet', 'clientid'); $clientSecret = get_pconfig(local_user(), 'appnet', 'clientsecret'); } $app = new AppDotNet($clientId, $clientSecret); try { $token = $app->getAccessToken($a->get_baseurl() . '/appnet/connect'); logger("appnet_connect: authenticated"); $o .= t("You are now authenticated to app.net. "); set_pconfig(local_user(), 'appnet', 'token', $token); } catch (AppDotNetException $e) { $o .= t("<p>Error fetching token. Please try again.</p>"); } $o .= '<br /><a href="' . $a->get_baseurl() . '/settings/connectors">' . t("return to the connector page") . '</a>'; return $o; }