本文整理汇总了PHP中LinkedIn::setState方法的典型用法代码示例。如果您正苦于以下问题:PHP LinkedIn::setState方法的具体用法?PHP LinkedIn::setState怎么用?PHP LinkedIn::setState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinkedIn
的用法示例。
在下文中一共展示了LinkedIn::setState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Share
function Share()
{
$config = (include "/config.php");
$li = new LinkedIn(array('api_key' => $config['linkedin_client_id'], 'api_secret' => $config['linkedin_client_secret'], 'callback_url' => $config['domain'] . "/linkedin/login/success"));
$li->setAccessToken($_SESSION['linkedin_token']);
$li->setState($_SESSION['linkedin_state']);
$hasParams = false;
$comment = "";
$title = "";
$description = "";
$url = "";
$source = "";
$visiblity = "";
if (isset($_POST['title']) && $_POST['title'] != "") {
$hasParams = true;
$title = $_POST['title'];
}
if (isset($_POST['description']) && $_POST['description'] != "") {
$hasParams = true;
$description = $_POST['description'];
}
if (isset($_POST['url']) && $_POST['url'] != "") {
$hasParams = true;
$url = $_POST['url'];
}
if (isset($_POST['source']) && $_POST['source'] != "") {
$hasParams = true;
$source = $_POST['source'];
}
if (isset($_POST['comment']) && $_POST['comment'] != "") {
$comment = $_POST['comment'];
}
if (isset($_POST['visiblity']) && $_POST['visiblity'] != "") {
$visiblity = $_POST['visiblity'];
} else {
$visiblity = "anyone";
}
if (!$hasParams) {
return "Missing params";
exit;
}
$post = array('comment' => $comment, 'content' => array('title' => $title, 'description' => $description, 'submitted_url' => $url, 'submitted_image_url' => $source), 'visibility' => array('code' => $visiblity));
//echo $li->getAccessToken();
try {
$li->post('/people/~/shares', $post);
} catch (Exception $ex) {
return $ex->getMessage();
}
return 'success';
}