Topic-icon Ability to link a Facebook page to the profile viewed ?

Active Subscriptions:

None
14 years 5 months ago #16754 by activha

alzander wrote: We should be able to detect the Page ID

If we ask for permission for read_insights or manage_pages, will JFBConnect allow us to retrieve the data and where can it be accessed ? is there a way to map it somewhere in Joomla ?
I have set up something with CB content module that may satisfy our needs if we have the above info

Thanks for the good luck ;-)
We'll need it
The topic has been locked.
Support Specialist
Jean Claude,
Permissions are granted to users, not applications, so that wouldn't work.

I did just look it up, and you can get the Page's ID when a Page is viewed. I think the following would be the easiest, yet crude, way of doing what you're looking for if you know all the owners of any Pages that may be visited:
$pageId = $request['page'];
if ($pageId == '12345')
  $userId = 62;
else if ($pageId == '34342')
  $userId = 78;
else // Unknown page
  $userId = 99;
Just put that code above all the other code I gave you above, then, in the comprofiler link, update it to use the $userId parameter you found in the new code.

Hope that helps get you going. It's definitely simpler than storing stuff in a database and doing lookups all over the place, but it's also much more hard-coded than is ideal.

Either way, good luck, again!
Alex
The topic has been locked.
Active Subscriptions:

None
14 years 5 months ago #16779 by activha
I took you idea and set up a field in Community Builder called cb_fblikes to register all user_likes, add the user_likes permission to JFBConnect and map the user interests to the CB field.

Then I drafted the following code :
//modifications pour activ ha
                    	$pageId = $request['page'];
                    	if (isset($pageId[1])) {
                    	// find userlikes in BD todo search for contains instead of egals
  						$db->setQuery("select id from #__comprofiler where block = 0 and cb_fblikes = '" . $pageId[1] . "'");
  						$row = $db->loadResult();
						 if ($row) {
						 	$userId = $row;
						 }
						 else // unknown page set demo user
						 	$userId = 694;


                    	$profileRedirect = $jSession->get('jfbcProfileRedirect', true); //pour rediriger une seule fois vers user ou demo 694

						if ($profileRedirect)
						{ 
							$jSession->set('jfbcProfileRedirect', false);
                        	//$mappedFbUserId = $this->jfbcLibrary->getFbUserId(); 
                        	//$userMapModel = new JFBConnectModelUserMap(); 
                        	//$jUserId = $userMapModel->getJoomlaUserId($mappedFbUserId);
                        
                        	$jUserId = $userId;
                        
                        	if ($jUserId && (JRequest::getCmd('option') != 'com_comprofiler' || JRequest::getCmd('user') != $jUserId)) // FB user has a profile on the Joomla site 
                        	$app->redirect('index.php?option=com_comprofiler&task=userprofile&user='.$jUserId); 
                        	else if (!$jUserId && (JRequest::getCmd('option') != 'com_comprofiler' || JRequest::getCmd('user') != '694')) // Fixed profile, no FB user on Joomla site 
                        	
                        	//redirection sur deals demo
                        	$app->redirect('index.php?option=com_m2c&view=m2c&Itemid=438'); 
                        }
                        // fin des modifications
                        $tabTemplate = $this->configModel->getSetting('canvas_tab_template');
                        $app->setTemplate($tabTemplate);

However it does not seem that the pages are registered in my field.
Can you tell me if users interests really contain pages as described by FB docs ?
And in this case, is this the page id or the page title which is displayed ? if the title is there any way to find the id from the title ?

We are moving forward :-)
Hope this may be useful for you too somehow
The topic has been locked.
Support Specialist
If you're using the field mapping setting in the JFBConnect Profiles tab, the interests field from Facebook will return text strings like "flowers, birds, plants", not IDs of items you like, so you won't be able to use that to check if the user like's the page. If there's a specific doc you were looking at, linking to it may be able to help me understand what you were looking at vs what JFBConnect does with the profile info.

Beyond that though, you shouldn't need to see if the user Like's the page. That's already passed in the $request variable as $request. Again though, neither what you were trying, or the Liked value that's passed from Facebook will let you know if a) the user is an admin of that Page or b) if the user has account on your Joomla site.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
14 years 3 months ago #19102 by activha
Hello Alex
I am coming back on this subject with JFBC 4.1.2
We have ask for manage_pages in the JFBC permission request. With this permission can we know the id of the pages that the user manages, or only their names ? how can we interact with these pages ?

If yes we should be able to compare the id of the visited page on FB with our DB and only show the data from the user to which the page id belongs (as administrator of the page), with a default data if there is no page id ?

Thanks
Jean Claude
The topic has been locked.
Support Specialist
Jean Claude,
The manage_pages feature allows you to administer a user's pages for them. With this permission, if the user is an owner of a Facebook Page, then you would be given permission to admin the page as well, as if you were the user. This means you can change the name, change the picture, post comments, and generally do anything an admin could do. JFBConnect doesn't directly expose those abilities, but having the permission would allow you too.

I honestly think that if you make this a requirement of your users, they will likely deny it.. or at least, they probably should if they're at all security conscious. I'd really recommend against requesting that permission as it could look bad that you need that permission for a user to access your app.

As for your actual question though, yes, with that permission, you'd be able to fetch the IDs of any Pages that user administers. We haven't done much with Page administration through the API. It's something we'll be evaluating for the 4.2 or 4.3 release, but even then, it would only be for the administrator of the Joomla site to be able to push content from Joomla to their page. The abilities you have with the manage_pages permission can be found below:
developers.facebook.com/docs/reference/api/page/

Hope that helps explain. Again, I'm not exactly sure what you're trying to do with the Page admin stuff, but I don't think the manage_permissions is the right request to ask of all your users. Many users won't understand it (they don't have Pages at all) and the ones that do will be very leary as to why you want to administer their Pages. In both cases, I think simply requesting the permission may put-off more users than it benefits you and your site.

Alex
The topic has been locked.
Active Subscriptions:

None
14 years 3 months ago #19202 by activha
Alex
Thanks for your explanation regarding the potential permissions problem with our users.

alzander wrote: , it would only be for the administrator of the Joomla site to be able to push content from Joomla to their page

This is the kind of thing that we want to achieve.
Our users have their pages on our website with their products that they sell through their pages. (for instance see activ-ha.com/userprofile/demo.html )
We want them to be able to show only their products on their facebook pages when our application is active on their FB page and we detect that the page belongs to them or is administered by them. (in this case their products will be viewed by ALL Fb users)

Is there a way to achieve this ?
As I said we will have hundreds of users, so there is no way to map manually. We would like a way to either detect the FB page ID and retrieve if one of the admins/owner is one of our users (then show its Activ HA page only for all visitors on FB), or find something simple for our users to do in order to link to their FB page if they have own set up with our application.

Thanks for your input
Jean Claude
The topic has been locked.
Support Specialist
I think I understand what you're looking for now, but let me re-phrase it in easy bullet points to make sure we're on the same page:
1) You have user's on your site that have a special page of their products. We'll call these user's "owners".
2) You want the owner's to be able to show their products in their Facebook Page using a Page Tab.
3) You want the process of linking the FB Page to the owner to be automated in some way.
4) When visitors go to the user's Page Tab, they should see the products.

If this is the case, and I'm pretty sure it is, you shouldn't need the manage_page permission from owners, and definitely wouldn't want to ask it from all users. The manage_page permission would allow you to automatically add your Page Tab to their Facebook Page, which would be nice. However, you can also just link to:
https://www.facebook.com/dialog/pagetab?app_id=YOUR_FB_APP_ID&display=popup&next=http://www.YOURSITE.com/
The owner can click this link, select their page, and add your Page Tab to it.

Matching up the Facebook Page to the owner is now the more difficult part. Could you create a page for the owner to fill out some information that would get stored in the database? This could be in their CB profile, or somewhere else. If so, if you can simply ask them what their Facebook Page URL is, we could easily use that to match up with the user.

That would be my recommendation. You could automatically fetch that information from the manage_pages permission, but there could be multiple Pages and you'd need to parse things out and figure out a lot of stuff. Simply asking the user for their Page URL and making them click the link above to add it seems like an easy/quick first step to get you going now.

Let me know,
Alex
The topic has been locked.
Active Subscriptions:

None
14 years 3 months ago #19250 by activha
Alex,
Thanks you for these very wise recommendations !

I have set up a new CB [cb_fbpage2] field asking for owners to fill it with the url of their FB page, we can even have several fields for several pages.

You have understood what we want to achieve. I would simply add to 4) that all visitors should see only the owner's products when they go to the page tab. But I guess that we can deal with this point with CB and Enmasse components.

Now if an owner fills the required field with its page url, how can we check it against the CB table with JFBC connect ?

Could you help me on this ?

thanks a lot
Jean Claude
The topic has been locked.
Active Subscriptions:

None
14 years 3 months ago #19515 by activha
Alex
Could you tell me how to detect the page name with JFBC in order to match it with our CB field ?

Thanks
Jean Claude
The topic has been locked.