function socialmedia_foursquare_parser in Social media 7
1 string reference to 'socialmedia_foursquare_parser'
File
- ./
socialmedia.platforms.inc, line 270 - Defines social media platforms
Code
function socialmedia_foursquare_parser($values, $scope = 'site') {
$profile = array(
'url' => '',
'username' => '',
'userid' => '',
);
$str = $values['url'];
$pattern = '/(?:http:\\/\\/)?(www\\.)*(foursquare\\.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_foursquare_url', t('Foursquare URL invalid.'));
}
return FALSE;
}
$a = explode('foursquare.com/', $str);
$profile['url'] = 'foursquare.com/' . $a[1];
$profile['userid'] = $profile['username'] = $a[1];
if (isset($values['username']) && trim($values['username'])) {
$profile['username'] = $values['username'];
}
if (isset($profile['username'])) {
return $profile;
}
//dsm($profile['url']);
form_set_error('input_foursquare_username', t('Cannot derive Foursquare username for this type URL. Please provide a username.'));
return FALSE;
}