Posting Comments Sync with Facebook

Phoca Gallery - image gallery extension
blutiges
Phoca Newbie
Phoca Newbie
Posts: 7
Joined: 15 Mar 2011, 00:03

Posting Comments Sync with Facebook

Post 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
blutiges
Phoca Newbie
Phoca Newbie
Posts: 7
Joined: 15 Mar 2011, 00:03

Re: Posting Comments Sync with Facebook

Post 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


User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49297
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Posting Comments Sync with Facebook

Post 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?
If you find Phoca extensions useful, please support the project
blutiges
Phoca Newbie
Phoca Newbie
Posts: 7
Joined: 15 Mar 2011, 00:03

Re: Posting Comments Sync with Facebook

Post 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
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49297
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Posting Comments Sync with Facebook

Post by Jan »

Hallo, dann siehe z.B:
components/com_phocagallery/views/category/tmpl/default_comments-fb.php

dort ist das Link erzeugt.
If you find Phoca extensions useful, please support the project
blutiges
Phoca Newbie
Phoca Newbie
Posts: 7
Joined: 15 Mar 2011, 00:03

Re: Posting Comments Sync with Facebook

Post by blutiges »

Vilen Dank für die info,,
hab es gelöst bekommen ,)
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49297
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Posting Comments Sync with Facebook

Post by Jan »

Ok
If you find Phoca extensions useful, please support the project
Post Reply