i want to make custom filed that contains facebook like count for the post url
to get the likes i used this code
function fb_count(){
$link = get_permalink($post->ID);
$content = file_get_contents("http://api.facebook.com/restserver.php?method=links.getStats&urls=".$link);
$element = new SimpleXmlElement($content);
$shareCount = $element->link_stat->total_count;
return $shareCount;}
which i don’t know how to store the Facebook data in custom filed
i tried this code but it dos not work
<?php $like_key = 'likes_count';
$link = get_permalink($id);
$content = file_get_contents("http://api.facebook.com/restserver.php? method=links.getStats&urls=".$link);
$element = new SimpleXmlElement($content);
$shareCount = $element->link_stat->total_count;
$key1_values = get_post_custom_values($like_key, $id);
foreach ( $key1_values as $value )
update_post_meta($id,$like_key,$shareCount, $value); ?>
i wanna know i what i am doing wrong