本文整理汇总了PHP中connection::find方法的典型用法代码示例。如果您正苦于以下问题:PHP connection::find方法的具体用法?PHP connection::find怎么用?PHP connection::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类connection
的用法示例。
在下文中一共展示了connection::find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insertUserConnection
public static function insertUserConnection($user)
{
$user_id = $user->id;
$token = $user->token;
$user_connection_data = "https://api.linkedin.com/v1/people/~/connections?id,first-name,last-name,headline,summary,industry,member-url-resources,picture-urls::(original),location,public-profile-url,site-standard-profile-request&format=json&oauth2_access_token={$token}";
//echo $user_connection_data;exit;
$ch = curl_init($user_connection_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$data = curl_exec($ch);
curl_close($ch);
$user_connection = json_decode($data);
Log::alert('User connection fetch');
/* for($i=0;$i<count($user_connection->person);$i++)
{
print_r($user_connection->person[$i]->{'first-name'});
} */
//echo "<pre>========="; print_r($user_connection); echo "</pre>========"; die;
if (!empty($user_connection->values)) {
$group = new Usersgroup();
$group->user_id = $user_id;
$group->group_id = 1;
$group->save();
Usersconnection::where('user_id', '=', $user_id)->delete();
foreach ($user_connection->values as $key => $value) {
if (!empty($value->id) && $value->id != 'private') {
if (!isset($value->publicProfileUrl) || $value->publicProfileUrl == '') {
$publicProfileUrl = $value->siteStandardProfileRequest->url;
} else {
$publicProfileUrl = $value->publicProfileUrl;
}
$connection = new Connection();
$connection = Connection::firstOrCreate(array('networkid' => $value->id));
if ($connection['user_id'] != '') {
$Connuser = User::find($connection['user_id']);
/* $Connuser->fname = @$value->firstName;
$Connuser->lname = @$value->lastName;*/
$Connuser->location = @$value->location->name;
$Connuser->industry = @$value->industry;
$Connuser->piclink = @$value->pictureUrl;
$Connuser->linkedinurl = @$publicProfileUrl;
$Connuser->headline = @$value->headline;
$Connuser->save();
}
$connection_id = $connection['id'];
$connection = connection::find($connection_id);
$connection->networktype = 'linkedin';
if ($connection->user_id == '') {
$connection->fname = @$value->firstName;
$connection->lname = @$value->lastName;
}
$connection->headline = @$value->headline;
$connection->industry = @$value->industry;
$connection->location = @$value->location->name;
$connection->piclink = @$value->pictureUrl;
$connection->linkedinurl = @$publicProfileUrl;
$connection->save();
$users_connections = new Usersconnection();
$users_connections->user_id = $user_id;
$users_connections->connection_id = $connection_id;
$users_connections->save();
$userDetail = User::find($user_id);
$userDetail->totalConnectionCount = $user_connection->_total;
$userDetail->save();
}
}
}
$userDetail = User::find($user_id);
if (empty($userDetail->totalConnectionCount)) {
$userDetail->totalConnectionCount = 0;
$userDetail->save();
}
$connection = new Connection();
$connection = Connection::firstOrCreate(array('networkid' => $user['linkedinid']));
$connection_id = $connection['id'];
$connection = Connection::find($connection_id);
$connection->networktype = 'linkedin';
if ($connection->user_id == '') {
$connection->fname = @$user['fname'];
$connection->lname = @$user['lname'];
}
$connection->headline = @$user['headline'];
$connection->industry = @$user['industry'];
$connection->location = @$user['location'];
$connection->piclink = @$user['piclink'];
$connection->linkedinurl = @$user['linkedinurl'];
$connection->user_id = $user_id;
$connection->save();
return true;
}