Get comment count on posts across site - facebook-graph-api

I have a site with lots of pages of content and a Facebook comment box (social plugin) on each one. Say, http://subdomain.site.org
I want to build a widget that searches that subdomain for the pages with the most comments on them and list them. Is there a way to do this?
Thanks!

its pretty easy to get the count of comments for each url
use fql:
SELECT url, comment_count, FROM link_stat WHERE url = " http://subdomain.site.org"
you can also get the comment count on all the urls at the same time (depending on how many urls)
SELECT url, comment_count, FROM link_stat WHERE url in ("url1", "url2", "url3" ... )
from facebook -FQL can handle simple math, basic boolean operators, AND or NOT logical operators, and ORDER BY and LIMIT clauses.
fql does not support CONTAINS() or anything else like that to use for searching all url's from a subdomain.
see here for the link_stat table - you can only query on column's that are indexable

Related

How do I access my query when using Haystack/Elasticsearch?

I originally followed this tutorial (https://django-haystack.readthedocs.org/en/latest/tutorial.html), and have so far been able to highlight my query within my returned results. However, I want to highlight this same query when visiting the next page that I load with a separate template. Is there any way to save/access this query so that I can highlight the same results within this other template?
Whenever I try and include a statement like this, I get an error, which I'm thinking is because I'm not trying to access the query properly.
{% highlight section.body with query html_tag "span" css_class "highlighted" %}
You have to send to the next page, the information that you use to highlight the results in the first page. You can use the request.session to store the data and call it in the next page, or you can send the sqs by the url to the next page.
If you want to know how to manage the search query set, and how to edit that kind of stuff, I recommend you to read the views.py forms.py and the elasticsearch_backend in the haystack folder at: "/usr/local/lib/python2.7/dist-packages/haystack"
This is the url for the documentation of Django Session: Django Session
This is the url for the documentation to pass parameters trhough url: URL dispatcher

'Hiding' form query from URL (Django 1.3)

I have a form with 6-7 fields. After user input, my webapp searches for those fields in a database and displays the results.
Now the issue is, that the URL ends up having all the form field names and their values in it.
result/?name=lorem&class=arc&course=ipsum
Now with the form having 7-8 fields the url ends up looking ugly.
Is there a Django technique to 'hide' these from the URL? Quotes around hide because I'd be okay with a completely different way to pass the objects to my database from the form as well.
Use a POST request. Here's the django docs on forms and a specific example using POST>. HTML-wise, all you need to do is change the method on the form tag.
I do not recommend to use POST requests for search. If you'll use GET it will be easer for user, he can just bookmark a link and save search or share search results with friends.

Getting a list of people who liked a URL with Facebook like button

I'm trying to find the list user ids who clicked on the liked a url address via Facebook Like button.
What I have found so far is that, I can use FQL to get the like information for a facebook object like this:
SELECT user_id FROM like WHERE object_id = 123
With this query I can find the user_id list who like and object. Therefore i need to find the object_id of the url using this query:
SELECT id FROM object_url WHERE url = 'http://localhost/facebook_page.html'
However when I put the returned id to the first query, no result is returned. I have also looked at the url_like table, however I cannot query url column as it's not indexed.
I have found from somewhere else that I have to add fb:admins tag, and force the administrator to like the link for an "open graph page node" to be created in the Graph. I tried that but it did not seemed to work. I don't know how I can check if the "page node" is created or not because I was not able to find any references at all.
user_like table does not work for me, as I cannot use the url column on the where clause.
http://developers.facebook.com/bugs/250668685029065
It seems like it's not possible for now.

How to organize URLs in django for views handling GET data and parsing URL?

I have a view that displays some movie data. I thought that it might be a good idea to have a view handle a an URL like movie-id/1234 to search for movie id 1234. Furthermore I would like to be able to enter the ID into a form and send that to a server and search for it. To do that I created a second entry in the urls.py file shown below.
urlpatterns = patterns('',
url(r'movie-id/(?P<movie_id>.+?)/$', 'movieMan.views.detailMovie'),
url(r'movie-id/$', 'movieMan.views.detailMovie', name='movieMan.detailMovie.post'),
)
So if I want to pass data to my view either via a URL or a GET or POST request I have to enter two urls or is there a more elegant way? In the view's code I am then checking if there is any GET data in the incoming request.
To make the second url usable with the template engine, where I wanted to specify the view's url using the {% url movieMan.detailMovie.post %} syntax I had to introduce a name attribute on this url to distinguish between these two.
I am not sure if I am thinking too complicated here. I am now asking myself what is the first url entry good for? Is there a way to get the URL of a movie directly? When do these kinds of URLs come into play and how would they be generated in the template ?
Furthermore I would like to be able to enter the ID into a form and
send that to a server and search for it.
Is this actually a search? Because if you know the ID, and the ID is a part of the URL, you could just have a textbox where the user can write in the ID, and you do a redirect with javascript to the 'correct' URL. If the ID doesn't exist, the view should return a Http404.
If you mean an actual search, i.e. the user submitting a query string, you'll need some kind of list/result view, in which case you'll be generating all the links to the specific results, which you will be sure are correct.
I don't think there is a more elegant way.
I did almost the same thing:
url( r'^movies/search/((?P<query_string>[^/]+)/)?$', 'mediadb.views.search_movies' ),
The url pattern matches urls with or without a search parameter.
In the view-function, you will have to check whether the parameter was defined in the url or in the query string.

Regular Expression Match for Google Analytics Goal Tracking

I have a coupon request form on every page on my website, when the coupon form is submitted you are taken to the same page you are on with an additional "?coupon=sent" parameter added to the query string. I would like to be able to track any page url wiht ?coupon=sent on the end as a goal. Currently, I have this:
/[^.][.php][\?coupon\=sent]+
which does not seem to be doing the trick. Any ideas?
Use this one:
/\?coupon=sent/