本文整理汇总了PHP中LinkedIn::share方法的典型用法代码示例。如果您正苦于以下问题:PHP LinkedIn::share方法的具体用法?PHP LinkedIn::share怎么用?PHP LinkedIn::share使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinkedIn
的用法示例。
在下文中一共展示了LinkedIn::share方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUserStatus
/**
* {@inheritdoc}
*/
function setUserStatus($status)
{
$parameters = array();
$private = true;
// share with your connections only
if (is_array($status)) {
if (isset($status[0]) && !empty($status[0])) {
$parameters["title"] = $status[0];
}
// post title
if (isset($status[1]) && !empty($status[1])) {
$parameters["comment"] = $status[1];
}
// post comment
if (isset($status[2]) && !empty($status[2])) {
$parameters["submitted-url"] = $status[2];
}
// post url
if (isset($status[3]) && !empty($status[3])) {
$parameters["submitted-image-url"] = $status[3];
}
// post picture url
if (isset($status[4]) && !empty($status[4])) {
$private = $status[4];
}
// true or false
} else {
$parameters["comment"] = $status;
}
try {
$response = $this->api->share('new', $parameters, $private);
} catch (LinkedInException $e) {
throw new Exception("Update user status update failed! {$this->providerId} returned an error: {$e}");
}
if (!$response || !$response['success']) {
throw new Exception("Update user status update failed! {$this->providerId} returned an error.");
}
return $response;
}
示例2: updateLinkedInStatus
function updateLinkedInStatus()
{
$API_CONFIG = array('appKey' => LINKEDIN_API_KEY_PUBLIC, 'appSecret' => LINKEDIN_API_KEY_PRIVATE, 'callbackUrl' => NULL);
$sql = "select `username`, `access_token`, `access_token_secret` FROM `love_users` where `linkedin_share` = 1;";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
$sql = "select count(*) as loves ,count(distinct giver) as givers from love_love where receiver = '" . $row['username'] . "' and at > DATE_SUB(CURDATE(),INTERVAL 7 DAY);";
$result2 = mysql_query($sql);
$row2 = mysql_fetch_assoc($result2);
if ((int) $row2['givers'] > 0 && (int) $row2['loves'] > 0) {
$OBJ_linkedin = new LinkedIn($API_CONFIG);
$OBJ_linkedin->setTokenAccess(array('oauth_token' => $row['access_token'], 'oauth_token_secret' => $row['access_token_secret']));
$response = $OBJ_linkedin->share('new', array('comment' => "This week's love stats: " . $row2['loves'] . " love from " . $row2['givers'] . " people."), FALSE);
//DEBUG OAUTH TOKENS IF NEEDED
/*
if($response['success'] === TRUE) {
error_log("DATA SENT TO LINKEDIN!");
} else {
error_log("Error revoking user's token:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($OBJ_linkedin, TRUE) . "</pre>");
}
*/
}
}
}
示例3: array
$OBJ_linkedin->setTokenAccess($_SESSION['oauth']['linkedin']['access']);
// prepare content for sharing
$content = array();
if (!empty($_POST['scomment'])) {
$content['comment'] = $_POST['scomment'];
}
if (!empty($_POST['sid'])) {
$content['id'] = $_POST['sid'];
}
if (!empty($_POST['sprivate'])) {
$private = TRUE;
} else {
$private = FALSE;
}
// re-share content
$response = $OBJ_linkedin->share('reshare', $content, $private);
if ($response['success'] === TRUE) {
// status has been updated
header('Location: ' . $_SERVER['PHP_SELF']);
} else {
// an error occured
echo "Error re-sharing content:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($OBJ_linkedin, TRUE) . "</pre>";
}
break;
case 'unlike':
/**
* Handle 'unlikes'.
*/
// check the session
if (!oauth_session_exists()) {
throw new LinkedInException('This script requires session support, which doesn\'t appear to be working correctly.');
示例4: linkedInShare
/**
* this function used to share html post
* @author Ahmed <a.ibrahim@objects.ws>
* @param string $appKey
* @param string $appSecret
* @param string $user_oauth_token
* @param string $user_oauth_token_secret
* @param string $comment 'empty' if not
* @param string $title 'empty' if not
* @param string $submittedUrl 'empty' if not
* @param string $submittedImageUrl 'empty' if not
* @param string $description 'empty' if not
* @return response done on success or faild on faild
*/
static function linkedInShare($appKey, $appSecret, $user_oauth_token, $user_oauth_token_secret, $comment, $title, $description, $submittedUrl, $submittedImageUrl)
{
//linkedIn config parameters
$config = array('appKey' => $appKey, 'appSecret' => $appSecret, 'callbackUrl' => '');
//create new linkedIn oauth object
$oauth = new \LinkedIn($config);
$linkedIn_oauth = array('oauth_token' => $user_oauth_token, 'oauth_token_secret' => $user_oauth_token_secret);
//set user token
$oauth->setTokenAccess($linkedIn_oauth);
// prepare content for sharing
$content = array();
if ($comment != 'empty') {
$content['comment'] = $comment;
}
if ($title != 'empty') {
$content['title'] = $title;
}
if ($submittedUrl != 'empty') {
$content['submitted-url'] = $submittedUrl;
}
if ($submittedImageUrl != 'empty') {
$content['submitted-image-url'] = $submittedImageUrl;
}
if ($description != 'empty') {
$content['description'] = $description;
}
// share content
$response = $oauth->share('new', $content, FALSE);
if ($response['success'] === TRUE) {
// status has been updated
return new Response('done');
} else {
// an error occured
// echo "Error posting network update:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($OBJ_linkedin, TRUE) . "</pre>";
return new Response('faild');
}
}