WordPress.org

Ready to get started?Download WordPress

Forums

Facebook Comments to WordPress
incorrect time && no count && is it possible to pull commenter avatar too ? (2 posts)

  1. Nadiamode
    Member
    Posted 3 years ago #

    sorry to make many post - but i cant append in previous post

    -----

    1. incorrect time - why time is incorrect ?
    i have go to add time offset in

    $createdDateTime->modify($timeOffsetToLocal.'25200 seconds');

    ----

    2. no comment count (number) display

    - it show only "0 Responses" IF that post only have comment from facebook plugin
    - it will show count number (ex. 8 Responses) only IF that post has at least 1 comment from blog's comment system

    - if you comment from blog you will see number but if only post comment from plugin, you wont see any number

    ---

    3. is it possible to pull commenter avatar too ?

    now you use only graph api , try FQL also work
    http://developers.facebook.com/docs/reference/fql/comment/
    http://developers.facebook.com/docs/reference/fql/

    this is example code from other plugin that they use simple api to pull user avatar

    public function fb_get_comments($post,$params=array()) {
    		##		http://developers.facebook.com/docs/reference/fql/comment/
    		##		http://developers.facebook.com/docs/reference/fql/link_stat/
    		$link = (!empty($params['xid'])) ? $params['xid'] : (($post->ID) ? get_permalink($post->ID) : $this->currentURI);
    		$migrated = (!empty($params['migrated'])) ? $params['migrated'] : get_option($this->ns.'fbtools_comments_migrated');
    		##	FQL Query
    		$fql = 'SELECT fromid, text, time, username, id FROM comment WHERE xid = \''.urlencode($link).'\'';
    		if($migrated) {
    			$href = (!empty($params['href'])) ? $params['href'] : $this->currentURI;
    			$fql = 'SELECT fromid, text, time, username, id FROM comment WHERE object_id IN (SELECT comments_fbid FROM link_stat WHERE url = \''.urlencode($href).'\')';
    		}
    		$res = $this->fb_query($fql);
    		$xml = new SimpleXMLElement($res);
    		## 	Put Comments into Array
    		$comments = array();
    		if(isset($xml->comment)) {
    			foreach($xml->comment as $comment) {
    				$item = array(
    					'text' => (string) $comment->text,
    					'time' => (int) $comment->time,
    					'commenter' => $this->fb_graph((int) $comment->fromid),
    					'commenter_photo' => (string) 'https://graph.facebook.com/'.(int) $comment->fromid.'/picture'
    				);
    				array_push($comments,$item);
    			}
    		}
    		return $comments;
    	}

    <img src="https://graph.facebook.com/USER-ID/picture"/>

    http://developers.facebook.com/docs/reference/api/

    we know user id from graph api so we can use pull image

  2. ixiter
    Member
    Posted 3 years ago #

    The local timezone offset is calculated wrong in the plugin, since WP overrides the systems offset. So in WP, date('Z') always returns 0.

    We can fix it, without using a hard coded offset like you did in your example.

    Do this ...
    EDIT FILE: /wp-content/plugins/facebook-import-comments/classes/FacebookCommentImporter.php

    FIND (line 201): $timeOffsetToLocal = date('Z');

    REPLACE WITH: $timeOffsetToLocal = timezone_offset_get(new DateTimeZone(get_option('timezone_string', 'UTC')), $createdDateTime);

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic