function socialmedia_flickr_parser in Social media 7
1 string reference to 'socialmedia_flickr_parser'
File
- ./
socialmedia.platforms.inc, line 190 - Defines social media platforms
Code
function socialmedia_flickr_parser($values, $scope = 'site') {
$profile = array(
'url' => '',
'username' => '',
'username' => '',
);
$str = $values['url'];
$pattern = '/(?:http:\\/\\/)?(www\\.)*(flickr\\.com\\/)(\\w+)+/i';
//$pattern = '/^http:\/\/(www\.)?twitter\.com\/(#!\/)?(?<name>[^\/]+)(/\w+)*$/';
if (!preg_match($pattern, $str, $matches, PREG_OFFSET_CAPTURE)) {
if (trim($values['url'])) {
form_set_error('input_flickr_url', t('Flickr URL invalid.'));
}
return FALSE;
}
$a = explode('www.flickr.com/', $str);
$profile['url'] = 'www.flickr.com/' . $a[1];
$b = explode('/', $a[1]);
if ($b[0] == 'people' || $b[0] == 'photos') {
$profile['userid'] = $profile['username'] = $b[1];
}
if (isset($values['username']) && trim($values['username'])) {
$profile['username'] = $values['username'];
}
if (isset($profile['username'])) {
return $profile;
}
form_set_error('input_flickr_username', t('Cannot derive username for this type URL. Please provide a username.'));
return FALSE;
}