Page 1 of 1

Posting Comments Sync with Facebook

Posted: 15 Mar 2011, 00:12
by blutiges
Hi all,

I wanted to ask if its planned in future to be in sync with facebook comments to the pictures?

Because my wish is:
- If user comments a Picture in PhocaGallery the comment is send to facebook (not via fb:comment)
directly to the Image so that the Users in facebook also can see the comment on the picture like the users on your own page can do.


code for posting should be like that:

Code: Select all

			//Post Comment to Facebook
					
					if(!empty($_POST['comment']) && !empty($PicGETID) )
					{
						$commentUser = $_POST['comment'];
						
					$facebook->api('/'.$PicGETID.'/comments?access_token='.$access_token,'post',array('message' => $commentUser ) );
					
					
					
					//auf User seite ausgeben
					$facebook->api('/'.$me.'/feed?access_token='.$access_token, 'post', array(
				'message' => $commentUser,
				'name' => 'App Name',
				'caption' => 'some text',
				//'picture' => 'https://graph.facebook.com/'.$PicGETID.'/picture',
				'link' => 'Link to the image of Phoca'


			));
and the code for requesting could be ;

Code: Select all



$commentsPic = $facebook->api('/'.$PicGETID.'/comments?access_token='.$access_token.'&fields=message,from');

					foreach ($commentsPic['data'] as $comment)
					{
						
					echo "<img src='https://graph.facebook.com/".$comment['from']['id']."/picture' border='0'></td>
					<td valign='middle'><a href='http://www.facebook.de/profile.php?id=".$comment['from']['id']."' target='_blank'>".$comment['from']['name']."</a>: ".$comment['message']." ";	

					}
is that planned or can you tell me what i need to edit to get this work?

I think its not that much effort, the only thing you need is read out the picture id from DB and do the request above ;)


It hope you can help me to integrate or have some solution for this.

Many Thanks

BluTiGeS

Re: Posting Comments Sync with Facebook

Posted: 15 Mar 2011, 23:53
by blutiges
Hallo zusammen, kann jemand mir mitteilen, wie ich die URL der comment page bekomme?

Ich habe es bereits mit $_SERVER... probiert und auch mit dem Phoca code rumprobiert, aber leider bin ich nicht genau fündig geworden ;).

Ziel ist es, dass man den Link zu dem Pic wo ein Kommentar hinterlassen wurde via App auf FAcebook postet.

Jedoch scheitert es an dem Link.

Jemand ne Idee?

Hier ist mal der bisherige Code, der auch schon erprobt wurde :) (FUll Initigrated)



in der components/com_phocagallery/views/comment/tmpl/default.php

folgendenes bei der facebook abfrage einfügen um direkt zu den Bildern ein Kommentar zu hinterlassen.

Code: Select all

else if($this->tmpl['externalcommentsystem'] == 2) {

//added by BluTiGeS
$model	= &$this->getModel();
$item	= $model->getData();



$facebook   = ItpcHelper::getFB(); //wenn ihr ITPCOnnect verwendet sonst einfach ein eigenes App connect via PHP machen.
 

 
$session = $facebook->getSession();

//link Pic ID auslesen
 $PicGETID = explode("_", $item->extl);
 $PicGETID = (int)$PicGETID [1];

if ($session)
{
	
   // print "Logged in!";    
    $access_token = $_SESSION['session']['access_token'];
		
		
			$commentsPic = $facebook->api('/'.$PicGETID.'/comments?access_token='.$access_token.'&fields=message,from,id');
			
			print "<div id='formComment'>";
				
					print "<form method='POST'>";
					print "Kommentar zum Bild hinterlassen: <input type='text' name='comment' style='width:300px; height:20px;'> <input type='submit' value='senden'>";
					print "</form>";
				
			print "</div>";
		if(!empty($commentsPic['data']))
			{
			print "<div id='galerie_comments'>";
			print "<table width='100%'>";
			
					foreach ($commentsPic['data'] as $comment)
					{
					print "<tr><td>";
						if($commentCount%2 == 0)
						{
							print "<div id='galerie_comment1'>";
						}
						else{
						print "<div id='galerie_comment2'>";
						}
					
					print "<img src='https://graph.facebook.com/".$comment['from']['id']."/picture' border='0'><div id='commentText'><a href='http://www.facebook.de/profile.php?id=".$comment['from']['id']."' target='_blank'>".$comment['from']['name']."</a>: ".$comment['message']." ";	

					print "</div>";
					print "</td></tr>";
					
	
					//Zähler increase
					$commentCount++;
					}
				print "</table>";
			print "</div>";
		
				
				
			} //ende if(!empty($commentsPic))
		

					//Post Comment to Facebook
					
					if(!empty($_POST['comment']) && !empty($PicGETID) )
					{
				
					$commentUser = $_POST['comment'];
						
					$facebook->api('/'.$PicGETID.'/comments?access_token='.$access_token,'post',array('message' => $commentUser ) );
					
				
					//PAge refreshen		
					print "<script type='text/javascript'>location.href = location.href;</script>";
					}
					
}else{
		echo "<div align='center'>Du musst dich mit deinem FB Account hier anmelden, bevor du kommentieren kannst.</div>";
	  }

 
 
//ENd added by BluTiGeS



Re: Posting Comments Sync with Facebook

Posted: 17 Mar 2011, 01:20
by Jan
Hallo,
Hallo zusammen, kann jemand mir mitteilen, wie ich die URL der comment page bekomme?
Leider verstehe ich nich, wo man es bekommen soll?

Re: Posting Comments Sync with Facebook

Posted: 17 Mar 2011, 21:30
by blutiges
Hallo Jan ;),

ich bräuchte diese URL "tld.de/gallery/5-dark-night-12032011/comment/43-external-image"

aus der Comment Seite heraus, damit ich diese als feed an Facebook übergeben kann, dass man auch vom Facebook aus auf das entsprechend kommentierte Bild gelangt.

Weißt du wie die Phoca gallery den Link erzeugt?

Es müsste ja eigentlich der Link zum Kommentieren auf der seite sein, wo die Bilder des Albums aufgelistet sind mit dem Kommentar symbol ;).

Genau diesen Link bräuchte ich in der comment Seite ;).

Vielen Dank

Grüße

Re: Posting Comments Sync with Facebook

Posted: 25 Mar 2011, 00:23
by Jan
Hallo, dann siehe z.B:
components/com_phocagallery/views/category/tmpl/default_comments-fb.php

dort ist das Link erzeugt.

Re: Posting Comments Sync with Facebook

Posted: 25 Mar 2011, 18:16
by blutiges
Vilen Dank für die info,,
hab es gelöst bekommen ,)

Re: Posting Comments Sync with Facebook

Posted: 26 Mar 2011, 01:45
by Jan
Ok