Facebook comments plugin, URL aliases? - javascript

I'm using Facebook comments plugin to display a comment area in each of my product pages (http://mydomain/product/:productid).
<div class="fb-comments" data-href="http://mydomain/product/1" data-order-by="social" data-width="100%" data-numposts="5" data-colorscheme="light"></div>
This works great, except that each of those comment area are "instantiated" by url. Facebook knows how to retrieve each pages comments thanks to the provided URL.
Problem is, i have subdomains like http://dev.mydomain/product/1 or http://alpha.mydomain/product/1 and i would like to retrieve the comments left on http://mydomain/product/1 on those subdomains.
So, is there any way to declare "aliases" to http://mydomain/product/1, in order to retrieve the same comments on http://dev.mydomain/product/1 or http://alpha.mydomain/product/1 ?
Edit : Still stuck here, http://alpha.mydomain.com and http://www.alpha.mydomain.com have two different comments container, because urls are not the same...

Are you able to use JS to make a call to their Graph API? You can get the comments for a URL by making a GET call to their API:
https://graph.facebook.com/v2.6/?fields=og_object{comments}&id=<YOUR_URL>&access_token=<YOUR_TOKEN>
Facebook stores and retrieves comments based on the full URL, but you could try passing the same URL to the Facebook javascript; that might give you what you want. Let me know what happens.

Related

How to remove the id from the url and submit the title in url using php

i am working on the job posting page in our website and we need to submit the each and every job title to be indexed with google instead of id's which are shown in url.
I need to see the each and every job title in URL instead of id's.
can any one help me how to do this.
you can check my site url from below link
http://www.anantha.co.in/viewJob.php?id=689
Kind Regards
Suresh
You have to work on HTACCESS to have this done. For example if you want your URL like example.com/title.html , it can be achieve by .htaccess by mod rewrite. You can get title as parameter as you can by GET.
A good example:
https://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/

How to programmatically get campaign/source/medium for current Visit in Google Analytics

I'd like to know how active are the users depending on the source/medium/campaign of the traffic they came from before sign up. I'm hitting wall when trying to get campaign/source/medium for the current visit from Google Analytics tracker in JS.
I found this tracker.get() method: https://developers.google.com/analytics/devguides/collection/analyticsjs/method-reference#get but they don't specify what are the possible values for 'fieldName'. I inspected the tracker object in Firebug and found out the screen attached screen grab:
Are these the only fields that I can query? Is reading any of the campaign fields possible? I understand that GA intends to be anonymous, but I figured this information is not really a secret...
If I can't retrieve this information from GA tracker, how would you approach this question? Should I set my own cookie whenever there's a visit with utm_ parameters and then read it if the visitor chooses to sign up?
I'm aware of this response: How do I extract Google Analytics campaign data from their cookie with Javascript? but a comment says parsing a cookie won't work for AdWords traffic..
I had to do something similar for a project. You need to think outside of the box to get this working. This will only work for cases where you put the campagn information in the url, for tagged url's.
1) On every page add server side code(php, asp .net) to parse the querystring and save the campagn/source/medium from the url in a session(or cookie)
2) Retrieve this information where you need it and process it.
You indeed need some custom javascript in order to achieve this.
I created an open source project for this that addresses the need quite simply:
https://github.com/ilkkapeltola/visitdata
Once you include the javascript library, you can call visitdata.get() and it'll return an object with things such as source, medium etc.

How to reshare a Facebook Post

i want to reshare a facebook post by letting my visitors go to some url and press share.
I looked into sharer.php and https://www.facebook.com/dialog/feed but both seem to only give me ways to let a user share a link and not reshare a facebook post.
I don't want to simple post the content of a post but to repost it, so the share count of the post also goes up.
Did i miss something, and is there a way to accomplish resharing via some api?
I've seen a post where someone was trying to do the same, unfortunately this is not possible with current API. You can only get the Post (with the post ID, if is public or with access token), scrape the information and create a new one.
David Crissc Reinberger is right that i can't reshare a post in a way that increments the share count.
Still there is a way to reshare a post that is a photo which increments the share count of the photo post:
Post an image
Get the Image link:
e.g.: https://www.facebook.com/photo.php?fbid=10152377142043306
Take the url and add it to sharer.php:
e.g.: https://www.facebook.com/sharer/sharer.php?u=https://www.facebook.com/photo.php?fbid=10152377142043306
This way you will really reshare the image and also increment the share count of the image post.
As you said, Facebook wont let you rehsrae their photo.
But using a proxy you can do that. And proxy gives you the flexibility to choose between sharer, or feed dialog.
Feed dialog fits better mobile web apps. Faster amd have better UI. Sharer don`t exist on mobile web apps.
https://images.weserv.nl/ does the job. Facebook accept the image as a picture param, and this way you are able to reshare thier posts.
Usage example (plus width and hight to improve performance)
'https://images.weserv.nl/?url=' + facebookImageUrl + '&h=200&w=200'

Is it possible to add a Facebook comment via an API for a specific page to avoid the need for the comment plugin?

Suppose I have a page, http://foo.com/bar. Is it possible to use the Graph API to let a use add a comment for that url to avoid the need to host the Facebook comment plugin?
I have a case where I want to let user sign in with Facebook but create my own comment UI. I know I can read all the comments with a call like this:
https://graph.facebook.com/comments?id=http://imdb.com
(assuming the link I care about is http://imdb.com).
However, I can't find a documented way to allow me to write a comment for a user given a specific access_token.
No, this is not possible. Previously there was a loophole to POST to the /comments endpoint with a messages parameter, but this is now closed. You must use the comments plugin to add comments.

Tag friends on post and location with javascript api

It's now possible to tag friends and location in feed post https://developers.facebook.com/blog/post/2012/03/07/building-better-stories-with-location-and-friends/ according to this link.
I would like to do it with the javascript api, with FB.ui method, so without the publish_stream authorization.
Does anybody know how I can do this ?
Well according to the docs, using an id of a place and adding the place parameter works on a graph api post. Unfortunately, after having tested this,it doesn't seem to be the case with the FB.ui method. It also looks like you cannot tag friends via this method either.
This page https://developers.facebook.com/docs/reference/dialogs/feed shows all the properties available, and it doesn't look like place is one of them. So I think this isn't possible at the moment I'm afraid. Perhaps you could raise a bug request for them to add it in

Categories