function dwsf_facebook_id() { $result = new stdClass(); $query = isset($_GET['query']) ? $_GET['query'] : ''; if ($query) { $result->facebook_id = dwsf_social_feed::fetch_id_facebook($query); } else { $result->error = true; } echo json_encode($result); exit(0); }
/** * Get Facebook id from facebook page name * * @param $username string User facebook name */ static function fetch_id_facebook($username) { $url = 'http://graph.facebook.com/' . $username; $content = dwsf_social_feed::getContent($url); $data = json_decode($content); if (isset($data->is_published) && $data->is_published) { return $data->id; } else { return false; } }