本文整理汇总了PHP中LinkedIn::sharePost方法的典型用法代码示例。如果您正苦于以下问题:PHP LinkedIn::sharePost方法的具体用法?PHP LinkedIn::sharePost怎么用?PHP LinkedIn::sharePost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinkedIn
的用法示例。
在下文中一共展示了LinkedIn::sharePost方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: share
/**
* Shares a new content on LinkedIn
**/
public function share($blog, $message = '', $oauth, $useSystem = false)
{
$message = $this->processMessage($message, $blog);
$content = $blog->intro . $blog->content;
$content = EasyBlogHelper::getHelper('Videos')->strip($content);
if ($blog->getImage()) {
$image = $blog->getImage()->getSource('frontpage');
}
if (empty($image)) {
$pattern = '/<\\s*img [^\\>]*src\\s*=\\s*[\\""\']?([^\\""\'\\s>]*)/i';
preg_match($pattern, $content, $matches);
$image = '';
if (isset($matches[1])) {
$image = $matches[1];
if (JString::stristr($matches[1], 'http://') === false && !empty($image)) {
$image = rtrim(JURI::root(), '/') . '/' . ltrim($image, '/');
}
}
}
$text = strip_tags($content);
// Linkedin now restricts the message and text size.
$message = JString::substr($message, 0, 700);
$text = JString::substr($text, 0, 256);
$content = array('title' => $blog->title, 'comment' => $message, 'submitted-url' => EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true), 'submitted-image-url' => $image, 'description' => $text, 'visibility' => 'anyone');
// Share to the person's account
$status = parent::sharePost('new', $content, true, false);
// Let's determine if we should auto post to company pages.
$config = EasyBlogHelper::getConfig();
$companies = trim($config->get('integrations_linkedin_company'));
if (!empty($companies) && $useSystem) {
$companies = explode(',', $companies);
// Share to company pages.
foreach ($companies as $company) {
$status = parent::sharePost('new', $content, true, false, array($company));
}
}
return true;
}
示例2: share
/**
* Posts a message on linkedin
*
* @since 5.0
* @access public
* @param string
* @return
*/
public function share(EasyBlogPost &$post, EasyBlogTableOAuth &$oauth)
{
// Get the content
$content = $post->getIntro(EASYBLOG_STRIP_TAGS);
// Get the blog image
$image = $post->getImage('thumbnail', true, true);
// If there's no blog image, try to get the image from the content
if (!$image) {
$fullcontent = $post->getContent('entry');
$image = EB::string()->getImage($fullcontent);
}
// If there's still no image, just use the author's avatar
if (!$image) {
$image = $post->getAuthor()->getAvatar();
}
$options = array('title' => $post->title, 'comment' => $oauth->message, 'submitted-url' => $post->getExternalPermalink(), 'submitted-image-url' => $image, 'description' => $content, 'visibility' => 'anyone');
// Satisfy linkedin's criteria
$options['description'] = trim(htmlspecialchars(strip_tags(stripslashes($options['description']))));
$options['comment'] = htmlspecialchars(trim(strip_tags(stripslashes($options['comment']))));
// Linkedin now restricts the message and text size.
// To be safe, we'll use 380 characters instead of 400.
$options['description'] = trim(JString::substr($options['description'], 0, 395));
$options['comment'] = JString::substr($options['comment'], 0, 256);
// Share to their account now
$status = parent::sharePost('new', $options, true, false);
// Determines if we should auto post to the company pages.
if ($oauth->system && $this->config->get('integrations_linkedin_company')) {
$companies = trim($this->config->get('integrations_linkedin_company'));
if (!empty($companies)) {
$companies = explode(',', $companies);
foreach ($companies as $company) {
$status = parent::sharePost('new', $options, true, false, array($company));
}
}
}
return true;
}