Source of file LinkedInPublish.php
Size: 1,011 Bytes - Last Modified: 2021-12-23T10:51:13+00:00
/var/www/docs.ssmods.com/process/src/code/LinkedInPublish.php
123456789101112131415161718192021222324252627282930313233343536373839404142 | <?php class LinkedinPublish extends Controller { public function postMessage($message) { //Share on linkedIn $siteConfig = SiteConfig::current_site_config(); $linkedIn = new Happyr\LinkedIn\LinkedIn( $siteConfig->LinkedInId, $siteConfig->LinkedInSecret ); $accessToken = $siteConfig->LinkedInAccessToken; $linkedIn->setAccessToken($accessToken); if ($linkedIn->isAuthenticated()) { //we know that the user is authenticated now. Start query the API $options = array( 'json' => array( 'comment' => $message, 'visibility' => array( 'code' => 'anyone' ) ) ); $result = $linkedIn->post('v1/people/~/shares', $options); if ($linkedIn->hasError()) { $msg = $linkedIn->hasError(); SS_Log::log($msg, SS_Log::ERR); return false; } return true; } else { //if not authenticated $url = $linkedIn->getLoginUrl(); return "<a href='$url'>" . _t('SocialMediaPage.LOGINTOLINKEDIN', 'Login to LinkedIn') . '</a>'; } } } |