链接按钮url计数php和wordpress

链接按钮url计数php和wordpress,php,wordpress,facebook,Php,Wordpress,Facebook,我的wordpress中有一个函数,它在我身后是facebook晒黑的数字,它给我带来的股数越准确,这是一篇帖子拥有的股数!我试图解决的功能,更多的是给一个错误,我需要帮助 以下功能: function ia_fb_count($url_post) { //Get the transient value from database $fbcount = get_transient( 'fblcount' ); if ( empty( $fbcount ) ){ //If

我的wordpress中有一个函数,它在我身后是facebook晒黑的数字,它给我带来的股数越准确,这是一篇帖子拥有的股数!我试图解决的功能,更多的是给一个错误,我需要帮助

以下功能:

function ia_fb_count($url_post) {
//Get the transient value from database
$fbcount = get_transient( 'fblcount' );
    if ( empty( $fbcount ) ){
        //If no value stored, get the like count
        $file = file_get_contents('http://graph.facebook.com/?ids="$url_post"');
            $jd = json_decode($file);
            $fbcount = number_format($jd->{'likes'});

        // Set the facebook likes transient value for 24 Hours
        set_transient('fblcount', $fbcount, 60*60*24 );
        // Also, return it at the same time
        return $fbcount;
    } else {
        // Transient Value is present, return it
        return $fbcount;
    }
}

在我的主题中调用函数,如下所示:

<?php
                $url_post = the_permalink(); 
                echo ia_fb_count($url_post);?>


有人能帮我吗?

这条线路可疑:

$file = file_get_contents('http://graph.facebook.com/?ids="$url_post"');
也许应该是这样

$file = file_get_contents('http://graph.facebook.com/?ids="'.$url_post.'"');

要计算喜欢、分享或评论,您还可以尝试第三方解决方案。是免费的,可以与WordPress配合使用。

您能指定错误的外观吗?