Menu
Download your TikTok Videos for FREE
Contact us
// Set the API key for the Social Blade API
$api_key = 'YOUR_API_KEY';
// Get the social media accounts from the custom field
$social_media_accounts = get_field('social_media_accounts');
// Loop through the social media accounts
foreach ($social_media_accounts as $account) {
// Set the API endpoint for the social media platform
$api_endpoint = 'https://api.socialblade.com/v2/' . $account['platform'] . '/channel/' . $account['username'] . '/basic';
// Set the API key as a query parameter
$api_endpoint .= '?key=' . $api_key;
// Make a request to the Social Blade API using the WordPress HTTP API
$response = wp_remote_get($api_endpoint);
// Check if the request was successful
if (is_wp_error($response)) {
// There was an error making the request
echo 'Error: ' . $response->get_error_message();
} else {
// The request was successful
$response_body = json_decode($response['body'], true);
// Extract the social media data from the response
$followers = $response_body['followers'];
$average_engagement = $response_body['average_engagement'];
$engagement_rate = $response_body['engagement_rate'];
$reach = $response_body['reach'];
$reach_rate = $response_body['reach_rate'];
$best_performing_posts = $response_body['best_performing_posts'];
// Display the social media data on the website
echo '
' . $account['platform'] . '
'; echo 'Followers: ' . $followers . '
'; echo 'Average engagement: ' . $average_engagement . '
'; echo 'Engagement rate: ' . $engagement_rate . '
'; echo 'Reach:
// Retrieve the HTML of the webpage
$html = file_get_contents('https://www.google.com/maps/place/Google/@37.4220041,-122.0862596,17z/data=!3m1!4b1!4m5!3m4!1s0x0:0x6c296c66619367e0!8m2!3d37.4219998!4d-122.0840662');
// Create a new DOMDocument object
$doc = new DOMDocument();
// Load the HTML into the DOMDocument object
@$doc->loadHTML($html);
// Create a new DOMXPath object
$xpath = new DOMXPath($doc);
// Use the DOMXPath object to search for the name and address elements
$name_elements = $xpath->query("//h1[@class='section-hero-header-title-title']");
$address_elements = $xpath->query("//span[@class='section-info-text section-info-line']");
// Extract the data from the elements
$name = $name_elements[0]->nodeValue;
$address = $address_elements[0]->nodeValue;
// Display the data on the webpage
echo '
' . $name . '
'; echo '' . $address . '
';