top of page

Jak zapytać facebook’a o liczbę „lubię to” dla konkretnego adresu?

Sprawa jest dość prosta. Należy skorzystać z Facebook API

Kod w php:

function iworks_get_fb_likes( $url )
{
    $query = sprintf( "select total_count from link_stat where url='%s'", $url );
    $call = "https://api.facebook.com/method/fql.query?query=" . rawurlencode($query) . "&format=json";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $call);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $output = curl_exec($ch);
    curl_close($ch);
    $fb = json_decode($output);
    if ( is_array( $fb ) ) {
        $fb = reset( $fb );
        if ( isset( $fb->total_count ) ) {
            return $fb->total_count;
        }
    }
    return 0;
}

Comments


© 2023 by Agnieszka Brocik Real Estate Consulting. Powered and secured by Wix

bottom of page