I would like to let a user enter a facebook page name and validate that it is a facebook page and nothing else.
To accomplish that I've used ajax to call graph.facebook.com/{str} where {str} is a pageName a user is requested to enter, but the problem is that any string can be entered and if a user enters a string which is a facebook profile, it will return a facebook object.
How do I validate using graph.facebook.com/{str} that {str} is a valid facebook page name ?
I've tried using graph.facebook.com/search?q={str}&type=page but it returns close results too even if the {str} that was entered wasn't found.
Thanks
Instead of using Graph API I would suggest you to instead use the Page FQL which is indexable by the name field, and would only return data if the name corresponds to a Facebook Page and not for a User.
Edit
select name from page where name='ign'
Which would give you the result for IGN's page, but if you do the same for any user it would return nothing.
Some fanpages don't have short username:
https://www.facebook.com/pages/Fanpage-name/FANPAGE_ID
in this case, you should send FANPAGE_ID instead of username. Valid fanpage will have fields like
"is_published": true,
"likes": 27134,
check graph api result for public profile:
http://graph.facebook.com/zuck
and fanpage:
http://graph.facebook.com/facebook
Related
I have the following method:
function CompleteFbData() {
FB.api('/me', 'get', {fields: 'id,name,email,birthday'}, function(response) {
$("#profile_full_name").val(response.name);
$("#profile_email").val(response.email);
$("#profile_telephone").focus()
$("#loginbutton").remove();
});
}
This should return me id, name, email and birthday from my user's facebook account. However, it sometimes will get me only the id and name.
Eg1:
returns email
Eg2:
doesn't return email
Since it's important that I always get the user email for my application, is there a way I can ensure it will always get the email?
Thanks for your time.
EDIT: I understand that a Facebook account doesn't necessarily have an e-mail associated to it, so I must change my application.
However, in the examples I printed, the accounts used were created by myself, both have e-mails associated to each one of the. Still it did not return the email in one of them.
Note: this happens a lot, sometimes it returns sometimes won't return. Couldn't understand why and when it happens.
Facebook api requests don't return email if the email isn't valid. Do both the emails you have used for the separate accounts have valid # addresses? also has the email been verified via facebooks verification email?
Try this and if it works..woohoo!
I am doing a query onto a class where I have a pointer to a User.
I do query.include('byUser') and when I log out the query result it's shown but when I try to get a specific attribute like email. It doesnt exist.
I also first thought it was odd that I have to get the User details by doing:
const userDetails = query.get("byUser").attributes;
Do I have to do .attributes? And also why isn't the email showing up. Everything else seems to show up in the attributes section.
Thanks
Please note that in parse, you can not query the email field of other users. you can see the email field only if you are the signed in user. This is a security mechanism.
A. If you want to get the email field for a user object, you can do two things:
Pass the user session token to the query.
new Parse.Query(Parse.User).get(<userId>,{sessionToken:<userSessionToken>});
Use master key. (Note: You have to set the master key before.)
new Parse.Query(Parse.User).find({useMasterKey:true});
B. Your include method is correct and it it will fetch the byUser object. You do not need to use .attributes.
UPDATE:
You can also set a publicEmail field in your User class which will not be filtered out by parse-server. to automate this, you can write a cloud code.
Cloud Code Example (on parse-server V 3.0.0 and above):
PLEASE NOTE THAT YOU CAN NOT USE ASYNC FUNCTIONS FOR PARSE-SERVER < V 3.0.0
Parse.Cloud.beforeSave(Parse.User, async req=>{
if (!req.original && !req.master && req.object.get('email')){
req.object.set('publicEmail',req.object.get('email'));
}
})
Now, if new user sign up, this cloud code will automatically adds a new field to the user object publicEmail which is not filtered by parse-server.
I'm making an app where users uses a custom view to login into a website. I got everything working, from passing the data from UITextFields to webView website, also i can submit the login and username using this code
NSString *performSubmitJS = #"var passFields = document.querySelectorAll(\"input[type='submit']\"); \
passFields[1].click()";
[webView stringByEvaluatingJavaScriptFromString:performSubmitJS];
How can I check if the user introduced wrong username and password? is there anyway to use something like
document.querySelectorAll
to check if user introduced wrong credentials?
I'm assuming your webpage reloads when you click the login button, which means you want to define this delegate method if you haven't already:
- (void)webViewDidFinishLoad:(UIWebView *)webView;
and you'll need to re-inject your javascript here to scan the page for some indication that an invalid password has been entered. You can use querySelector for this but you'll have to inspect the webpage for the bad password case and find an element that is uniquely displayed for bad passwords. It might be easier to just check something like if(document.body.innerHTML.indexOf('invalid password') > -1) window.location = 'WRONG_PASSWORD' (replace 'invalid password' with whatever the webpage says when you enter an invalid password) and you can implement:
- (BOOL)WebView:(UIWebView *)myWebView shouldStartLoadWithRequest:(NSURLRequest *)request;
and check to see if the URL ever equals WRONG_PASSWORD to know if the user entered a wrong password and react to it in objc.
I have an Instant Message feature on my site which uses a popup window. When a user makes an IM post, their picture is added to the post. I am able to save on a database query for each IM post (so the popup does not have to query the database to retrieve the user's picture for each post) by retrieving the stored user pic file name from a form (UserPicStorage...a separate query is not required to grab $sql['picture']...it's already present on each of the main pages when these pages load) on each of 5 non-popup, main pages (one page is an exception, see below) of my site as follows:
<form id="UserPicStorage"><input type="hidden" name="UserPic" value="<?=
$sql['picture'] ?>"></form>
I have an About Us page which does not need a database query to load. So to save a query if a user posts an Instant Message while on the About Us, I pass $sql['picture'] to the a href as follows:
About Us
so the popup can retrieve the userpic if there is an IM post while the user is on About Us.
However, the user can use AJAX on one of the 6 main pages to change his/her user picture.
So I can't use this:
About Us
because if the user changes his/her photo, $sql['picture'] (which was valid on page load)
is no longer the current photo. I did a lot of searching, but could find nothing to support
something like the following method:
About Us
I tried this and simply passed the literal string document.forms.UserPicStorage.UserPic.value. So did the following:
About Us
Is there any way to append the input value of a form directly to the a href?
You should just use
About Us
(well, probably you should encode $sql['picture'])
And when you make the AJAX request, update it as a success callback:
ajax.onreadystatechange = function() {
if (ajax.readyState===4 && ajax.status >= 200 && ajax.status < 300) {
/* AJAX successful */
myAnchor.src = "about.php?userpic=" + encodeURIComponent(
document.forms.UserPicStorage.elements.UserPic.value
);
}
};
I'm making a login page in JSP. I have an index.jsp page where the form exists and some javascript scriplets. Connectivity to oracle database and checking for username and password in database is done in check1.jsp file
My issue is that after entering username and password, when I press login button, I have linked the form to check1.jsp, if username and password matches and exist, it redirects to welcome.jsp , but if username doesnot exist or password is not matched I have to get back to index.jsp showing a small message below box that username doesn't exist OR Password is not matched, currently I am just redirecting to index.jsp.
How should I show that appropriate small message below login box on that same index.jsp page??
REDIRECT TO index.jsp?message=<your custom msg>
And then you can check if message parameter is set and get them via GET parameter
EDIT: (after comments)
I am not a java programmer but googling gives me this,
if(request.getParameter("message") == null) {
// User has opened index.jsp for first time (no redirection)
}
else{
// user has been redirected from check1.jsp
string message = request.getParameter("message");
// Do anything with message
}
You could have a flag that is triggered in check1.jsp and sent back to index.jsp.
and in index.php , you could put a check for the flag to display error if it's turned ON.