本文整理匯總了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;
}