I am developing an app, and I want to realize the "share" function, which can share the content to facebook or twitter. Every content has its own id, and I want to generate a hashed link when the "share" button is clicked. Say, if there is an essay A, and I want to share it to facebook, so I click the "share to facebook" button. Then it should generate a url, which looks like "http//my_app_backstage_server/essay/hash(id)", where hash(id) is not the real id of the content, but the hashed one. How can I implement this in Flask framework?
Thanks!
Facebook like button or twitter just create link to your page on facebook (if you don't want generate special links for this actions). So you need just provide content pages access.
You can generate random string or real hash and store it on database (don't forget that this value must be unique):
import random
import string
from hashlib import sha512
SIMPLE_CHARS = string.ascii_letters + string.digits
def get_random_string(length=24):
return ''.join(random.choice(SIMPLE_CHARS) for i in xrange(length))
def get_random_hash(length=24):
hash = sha512()
hash.update(get_random_string())
return hash.hexdigest()[:length]
I think you don't need have both id and hash access for content.
If you want generate links for any share button action (I realy can't understand why):
you must add route for this links;
you must add route to create link;
you can create link by ajax and share it after if you don't have user permission to share data;
you can create link by app (ajax or just link) if you have user permission to share data.
Related
I am trying to create a sample Online shopping application using SPRING+REST. I have a 1000 of products and I would like to make use of #RequestMapping("watches/{id}") annotation . But i dont know how to send the id form field value alone while submitting a form in jsp.
I want something like this
www.example.com/watches/1001
Please help me out
I guess you will have some jsp page which consists of all watches. This web page can be access by localhost:8080/watches URL.
If user click on any watches, user will land to localhost:8080/watches/{watch-id} page as the click on watch will redirect the request.
If your JSP is form based page, then user need to enter the watch-id ( or watch name which we need to map to watch id) and click on submit button will redirect the request to localhost:8080/watches/{watch-id}. Please let me know if you are ok with this.
Salon owners can create an account with their salon information on our platform and they get a page that they can use as a tab app.
I want to be able to serve all these pages from one app instead of having to install each one seprately and I also want to make the life of the salon owner easier by helping them to install the tab.
I know about the link I can create to help them install the app and I know that when a visitor visits the app that facebook will send the page ID. So far so good.
https://developers.facebook.com/docs/appsonfacebook/pagetabs/
But how do I make sure that when the salonowner follows the link to install the app that I get the page ID back (through callback or other) so that I can register which page ID belongs to which salon account.
I've read sone 2011 article about a callback but I can't find any recent info on this.
I think it should be possible as a lot of sites offer easy fb apps to businesses.
Any help would be welcome!
EDIT: Could this last piece of info in the Facebook link above be used to do this? I don't quite get it yet.
In addition, your app will also receive a string parameter called app_data as part of signed_request if an app_data parameter was set in the original query string in the URL your tab is loaded on. It could look like this: "https://www.facebook.com/YourPage?v=app_1234567890&app_data=any_string_here". You can use that to customize the content you render if you control the generation of the link.
Well... Preventing users from adding your application to their page is impossible. You can't prevent that.
What you will be able to do is to detect who has added your application and according to that, change the content (or not display it at all). So you'll have to start with a list of "allowed" page_ids to match to the accounts you want.
Your application will receive a signed_request each time a user arrives at your application (within a page). Inside that signed_request is information not only on the user but also on the page that the application is on (provided it is a page tab app).
Once you have obtained the signed_request, it will hold a page key which contains:
A JSON object containing the page id string, the liked boolean (set to
true if the user has liked the page, false if not) and the admin
boolean (set to true if the user is an admin of the page, false if
they're not). This field is only present if your app is being loaded
within a Page Tab.
So you'll be able to access the page_id from within this variable and make a decision on the type of content you want to be displayed.
Ok, after running some tests I found out that when you add a URL as 'next' parameter to the install URL Facebook will send the admin(user) back to this URL while adding an array to the request containing all the page Id's the app was installed to.
Like this: YOUR_CALLBACK_URL?tabs_added[ID]=1
Proved to be quite easy in the end
when i try to add to my website a FB Like Button with url+hash (example.com/#TEST)
and i try to click the like button - it shares the link without the hash in the news feed (example.com).
when i try to setup the button with "%23" instand of "#" (example.com/%23TEST) - it counts each hash separately in the count box.
is there any way to put a like button with hash - and still count the url without the hash?
Thanks!
When you are creating Facebook like buttons, Facebook uses cURL (correct me people) to acces your URL that has metadata. So if cURL sees different metadata, per URL, you will get different LIKE buttons.
But this doesn't happen; as on the server side, Facebook sees the same URL for every dynamic # enabled link. Since the part of the link before # is same. JavaScript (or any Behavior that can create a hash in URL) is ignored, obviously, since its Behaviour is a client only thing.
The best possible way would be to create the Button dynamically using JavaScript and change the URL-to-like of each button to something friendly without hash.
abc.com/def#part1
abc.com/def#part2
// to
abc.com/def/part1
abc.com/def/part2
Only for the curl script to see it as a different URL.
And when the user hits that link - abc.com/def/part1 - you would be needing server side help as well to redirect to the view part1 from the route def. So you would, in your router code, load only upto the route def (imagine MVC) and then ask the controller to load the view part1, with JavaScript enabled to append the URL hash #part1.
These hash tags are for client side actions not server side. You will not be able to use them in your Like Button.
I used to be able to construct a link like this:
http://www.facebook.com/connect/prompt_feed.php?message=hello
It would go to the page it currently does (click on the link to see) but it used to pre-populate the text field with the value of the message parameter. Now the text field is empty.
I suppose facebook changed this functionality, but is there a replacement that provides the same functionality? Note that I do not want to have to authenticate the user or connect them to an app. I am looking for a simple url that will just open a new window with a status message pre-populated so the user can just click "Share" (exactly how this prompt_feed.php used to work). Anybody know of a way to do this?
What about the feed dialog?
See here: https://developers.facebook.com/docs/reference/dialogs/feed/
Update: Ok, now I see that the user must have already authorized the app : [
Update 2: This isn't either a full replacement but an alternative - you could use the sharer php
http://www.facebook.com/sharer.php?u=yoursite.com&t=yourtitle
In that case yoursite.com should contain og meta tags. It does not prefill the message though : [
I'm looking to integrate the "like" button into a website, but I'm a little confused with the information available on the web. I read this article, which was in another stackoverflow article, but have some questions: http://www.saschakimmel.com/2010/05/how-to-capture-clicks-on-the-facebook-like-button/.
I've setup a "Page" already in facebook, and from what I understand in the link above, you need to setup an "App" to get an API key. What I don't understand though is that if I use this API Key, it's going to be pointing to my newly created "App", which has no fan base. How do I link this API Key, (or setup another key through the page admin), so I can have users "like" the real facebook page?
I want to run some javascript functions the moment a user likes the page, but I'm also a little confused on what API functions call, and whether these return a true/false value? I only really want to run these js functions if the user has not already liked the page..
Hope this all makes sense, would love any explanations you have to offer to point me in the right direction.
BUMP
after making a page and registering for it on face book, you will get a link, o trough the process again. Then just paste this link on your web site and you will get the like box. Paste it in a div tag.
You can also make a function in js which calls this like box and on its dependency you can call other js functions also.
//js code
function js()
{
create element div;
}
function other()
{
js();
}
If you just want an like button in your page , go to http://developers.facebook.com/docs/reference/plugins/like/
paste your fb page url in "URL to Like (?)" text box
get the code
paste in the div box of ur web site source code where you want it to appear