protected function post() { $url = $this->obj->getUrl(); $label = $this->obj->getTitle(); $comment = 'I asked this on ' . $this->Registry->Ini->SITE_NAME; if ($this->obj instanceof \Lampcms\Answer) { $comment = 'My answer to "' . $label . '"'; } d('$comment: ' . $comment . ' label: ' . $label . ' $url: ' . $url); $reward = \Lampcms\Points::SHARED_CONTENT; $User = $this->Registry->Viewer; $token = $User->getLinkedinToken(); $secret = $User->getlinkedinSecret(); try { $oLI = new ApiClient($this->aConfig['OAUTH_KEY'], $this->aConfig['OAUTH_SECRET']); $oLI->setUserToken($token, $secret); } catch (\Exception $e) { e('Error during setup of Linkedin ApiClient object ' . $e->getMessage() . ' in ' . $e->getFile() . ' on ' . $e->getLine()); return $this; } $func = function () use($oLI, $User, $comment, $label, $url, $reward) { try { $oLI->share($comment, $label, $url); } catch (\Exception $e) { return; } $User->setProfitPoint($reward); }; \Lampcms\runLater($func); }