a coupon (unique code) for a like clicked. what is the best way - facebook

The unique code is given to whoever clicked like (only the first time he clicks)
in order to make sure that he is not going to have a unique code again. I have to have his fb id in my database, but I read that it is impossible to know the fb id of someone who clicks like. Is there a solution?
If the like button will be on my fun page, is it possible then?
I have already all the process of generating the unique code, and checking in my db if the code was used or know, I only have to keep in my db also the fb id to make sure he will not get more then once.

Create fangate (differentiate likers non-likers).
Is is_liker get user id with basic permissions.
On return after accepting the permission request check if user already got code.
If user never got code give him. Else display error message.

Related

Using same id (not active one)

I've got an issue with a button.
I've got clients, and these all have a number ( Clients:: ClientID). Now I want to make a button in another form and send the active clientID to another application which will use this clientID to display information in that application about that client.
Now I've made a button with the open URL which contains following code snippet:
"http://localhost:12345/showClientFile?clientid=" & Clients::ClientID
When I click the button in viewlayout, the application always (no matter which record I'm in) the same clientID and not the clientID from the record that I'm in. When I check the URL in the browser, it is also that same id constantly. Am I missing something?
If you're on a layout that isn't linked to the Clients table occurrence, then there must be a relationship from whichever TO your layout is linked to to the Clients table. Otherwise you wouldn't see any value for Clients::ClientID.
You say you want to send the "active clientID". How do you, or the system, know what the active clientID is? Is it stored in a global variable, as in $$_ACTIVE_CLIENT_ID, or perhaps a global field, Clients::g_active_client_id? When you can say to yourself, "When I want to know what the active client ID is, I look here," then you know what will need to be done to edit the URL calculation.
"http://localhost:12345/showClientFile?clientid=" & $$_ACTIVE_CLIENT_ID

How do I get the current User Id with GoViral ANE

I am using the GoViral ANE for integrating with Facebook, specifically creating a leaderboard to display in my game.
I would like to highlight the current user's score, but I don't appear to have access to the id that is returned via the APP_ID/scores request.
For example, data is returned in the following format:
{"score":123,"user":{"name":"Colin","id":"1234"}}
The id portion is what I am looking to match to the current user to highlight the score.
I have tried GoViral.goViral.getFbAccessToken() but this is clearly the wrong thing.
I have also tried making a call out to get the current user's score, but it also requires a User Id to make the call, so I am a little stumped on this one.
Searching on Google doesn't seem to return any useful results either.
Thank you for your time.
Ah, it seems I don't need a user id to make the call after all.
The call I was attempting was the following:
From the Facebook developer site:
You can read the score for a person playing your game by issuing a
HTTP GET request to /USER_ID/scores with a user access_token.
With this code:
GoViral.goViral.facebookGraphRequest(
GoViral.goViral.getFbAccessToken() + "/scores",
GVHttpMethod.GET);
However the following call works:
GoViral.goViral.facebookGraphRequest(
"me/scores",
GVHttpMethod.GET);
So using "me" works instead of the user id, which returns:
{"score":123,"user":{"name":"Colin","id":"1234"}}
Allowing me to access the user id.

Meteor: The Correct way to access user information

I'm new to meteor and I am in the process of building my application, but I am running into some "best practice" questions.
I have three databases. One for the users, one for questions, and one for answers. Think of my site as a quora of sorts.
I am iterating through the questions, and I am having a hard time accessing the user information. At the moment when a question gets recorded, I record the question, and I only record the user's id. Coming from a rails background, this is usually all I need to access all the other information when I need it. I don't record the name and all the other info.
The question I have is what is the right way to access the user information? I am doing an each loop and it seems that Meteor.user is only for logged in users (only for my information basically). I can't seem to do something like Meteor.users.find({_id: this.user_id}) on the questions helper so that I could get each users info. It retrieves nothing like this.
In the examples I have seen, they usually record the information on the questions database. So they would record first,last name, and anything else that would be necessary. But this seems like I am recording information twice.
What is the right way to access this info? Should I record it when a question is posted or should I call it from the users database everytime?
I have tried accessing the info through a server method, but can't seem to get it to work. Been at this for a while so I though I should ask instead.
Thanks in advance!!
My solution would be just save the user_id field in db as you're doing right now,
If you save firstname or lastname with the questions they may change in future (considering the fact that in most sites we have option to change names)
I can't seem to do something like Meteor.users.find({_id:
this.user_id})
this is because user data is not availbale in the client, that is the reason why you can't see the data
solution is while publishing the question to client you should publish the information of the user too
Example
Meteor.publish('question,function(question_id){
var question = Question.findOne(question_id);
//get info of the question user
var user = Meteor.users.find({_id: question.user_id });
//you cannot publish findone result, so do another query
var ques_rec= Question.find({_id: question_id});
return [ques_rec, user];
});
Now, in the client side when you do I can't seem to do something like Meteor.users.find({_id: this.user_id}) you'll get the user data.
I think I found a solution. I haven't turned the autopublish off, so this seems to be working for now.
Template.questionItem.helpers({
user: function(){
user = Meteor.users.find({_id: this.user_id}).fetch();
return user[0]
}
I think basically you can search users, but for some reason if I do
Meteor.users.find({_id: this.user_id})
it returns an object and I can't seem to find the actual data.
But if I add the .fetch() at the end it will return an array for the user. So if declare it as a variable, I can access all the info by saying user[0].
I'm not sure if if this is the best way to do it in meteor, but it does seem to work.
So when I call the object in the handlebars I go something like:
{{user.profile.name}}
I think once I turn autopublish off I will have to do the same thing but from the server side.

PayPal , return page post values, how to access and use

I am wrestling with the PayPal service . I almost have it done . Last step, when the customer payed and has the last page, which stays open for 10 seconds and then redirects them to the page of your choosing.
What parameters, posts, etc are sent with that page opening? And how do I get access to them, so I can link the returning user with their created account (from ipn and my personalized database entry on the initial buyitnow)
I tried echo($_post). But it just shows .... Array() But no key value pairs.
I'd think there would be a lot more
I have rm=2. Set already.
Plus, I see some Get() cars in the URL but, nothing I can use .
Also, I am passing a custom variable , which is going through, and being used by the IPN to update the user account just fine. I just don't see how to connect the return page and the customer, preferably with the $custom var
Help?
Try using var_dump($_POST); instead of echo($_post);
Apparently, there are no POST variables coming from PayPal, they're all GET variables. A VAR_DUMP(GET) will show like 6 things, including your CUSTOM variable (id cm). I thought there would be more and it would be in POST format.
I also thought there would be a way to show everything, POST, GET, SESSION, etc. I even tried using Firefox NETWORK setting, but there were like 50 separate items. None of which seemed to contain my data. I'm sure it was there, but, hidden.

Saving changes to DB made in a webpage

I rewrote the title and content 3 times before posting it, I don't find the right way to ask this :P
I have a page that manage a list of notes, I have a CRUD on that page but the items are created and saved in javascript (using knockoutjs).
I create a new note, I add it to the model in javascript and it show up in the page.
The way Im saving the notes to the database is when I add it to the model, I send it via Ajax (async) to the server. So I have my note on screen and in the database really fast.
I send a note without Id to the server and EF will take care of the Id.
So far so good.
Imagine that I add a note but I dont refresh the webpage, so the note is in the database, is in the javascript model too but in the model it doesn't have the id yet.
I make some changes to the note and yeah, I want to update the note in the database... but... how?
I send my note to the server with the changes, but remember, the item still have no Id so I can't say:
Hey EF, give me the note with the ID == xx and we are going to update that note.
The others properties can be changed on the webpage so I have nothing that identifies the note apart from the Id, who doesn't work here.
I tried this:
Send the new note to the server, insert it on the database, retrieve it again (to pick the Id), send it back to javascript and update the object with the Id. So when I edit, I have the Id. Yeah, but the "save" call need to be sync and that destroy the experience.
Any ideas?
EDIT: The sync options is not that slow at the end but there have to be a async way and meh, the thing of "Insert on database", "Retrieve the last item I inserted" and "return back to the client" is a little hackish.
You could return the id of the new record in your asynch call. If you are using jQuery you can subscribe to the "success" callback and as long as your controller returns a JSON with the id of the new record you could update your model on the client side.
Even with this approach, you will need to have a way to identify the item updated on the client side (which is really the root of your question.) For that you can probably generate a random GUID on the client side, send it to the server when saving, and return it to jQuery when returning the ID so that you can identify the correct element to update on the page.