I want to set up a login page in which from anywhere on the site I can send a user to it and it will display a custom message along with it. I could use a redirect and a msg query param but is this the best way to do it?
I'm working with node.js but I'm interested in a universal solution.
If you are going for easy, you can just have GET data in the URL. But, that doesn't look that nice, if you want a rather long message, plus, GET has size restrictions, where POST (virtually) hasn't.
For using post data you could use the solution of this: JavaScript post request like a form submit question, but that gives a rather messy source code (if you want a somewhat longer text).
You could keep them in a database, and only send the ID of the message to a PHP page, and get it from the database (that's what I would do, but that doesn't mean it's a good idea, just amateur here!)
You can use jQuery or simply plain javascript to extract your message from the url; the relevant question that listed links to detailed code: jquery get querystring from URL.
Then depending on how you want it displayed, apply the extracted string to your situation.
Related
I've been reading some stuff about Facebook API's but as a non-programmer it's kinda hard to understand it all. It's probably a pretty simple question.
My question: is it possible to get all the information like coverphoto, time, description, location etc. from a (random) public Facebook event from just the URL of the event?
So I will have a field 'Insert event URL' on my page. Below that I will have some fields like 'Location' 'Start time' 'End time' which will be automatically filled in when the user inserts the URL of an event.
Please let me know! A link to the source with explanation etc. would also be really nice. (It's for a school project)
Yes you can. Ill try to explain you the simplest possible way to do that.
First of all go to : http://developers.facebook.com/apps and create an app.
Then, save the App access token which is: app_id|app_secret
Your url will be of format: https://www.facebook.com/events/{event-id}. Fetch the event id from this. Quite simple right?
Then you are going to use the facebook's powerful graph api. Just get the contents from : https://graph.facebook.com/{event-id}?access_token={app-access-token}
The list of all possible fields that you can get (only if set in the event of-course): https://developers.facebook.com/docs/graph-api/reference/user/events/#pubfields
That's it!
In my mod_perl2 app, on one page I link to with ?form_field_name=pre_fill_value tacked onto the URI if I want to pre-fill a particular form field for the user. However, the form itself is just <form method=post>, which posts back to the current page, GET query and all. I expected that Apache2::Request's param() routine would serve up either only the POST data, or the POST data first. Instead, it seems the GET data is given precedence, i.e., the prefill is honoured over the manually-user-fixed data.
The easy fix is to add action= and the current URI without the GET query, but I'm wondering why it was designed this way, and if there's a sneaky way around it, like some mod_perl2 option that would give POST data precedence. However, the easy fix can actually cause problems if un-overridden GET query values are expected to be passed on. So this workaround quickly grows, but why is it even this way in the first place?
Is there a way to send some a url (or other thing) to a site such that data in a form is already filled out? This is not to my own site that I control.
For example, I want to send a link to some airline flights and want to have the destination and date be automatically filled out when the link is opened.
I'm guessing not, but have gotten lucky here before :) Maybe with some kind of program or add-on or??
If its written with GET method so just try to play with the site and just put the url with all the args you found.
If it is POST, so you need to create an add-on or pretend to a browser, search the net for this kind of solution.
No, that's not possible, if the remote site is not ready for that.
Hey, so this is one of those questions that seems obvious, and I'm probably going to feel stupid, but here goes:
I'm doing a CodeIgniter site with a search. Think of a Google type input, where you'd search for "white huskies." I have a search results page that takes a URI (MySite.com/dogs/white huskies), and takes the third part, and performs the search on that term. I'd like this to be done in the URI, and no by POST so my users can bookmark results.
The problem I'm having is how to get that search button directed to Mysite.com/dogs/WHATEVER IS IN THE INPUT. How do I get the what is in the input part into the anchor href? I know I could do this with javascript, but I've heard it's bad practice to force people to have javascript for things this small.
Thanks for the help!
Read: Form redirect to URL containing query term? - pure HTML or Django
(asked for Django, but answer fits here too)
You could have an intermediate POST page that collects the form inputs and concatenates them into a valid URL which you can then redirect to. I'm not sure if this is good or bad SEO practice however, but I can't see another way of doing this without some Javascript intervention.
Perhaps you could look at doing the intermediate POST page which takes the values are redirects you to /search/dog/white/huskies, but also have a Javascript equivalent that does this on the fly on the form submit and does a window.location refresh to the same /search/dog/white/huskies?
Just my 2 pennies worth ;)
It is possible to have CodeIgniter work with $_GET variables and URI segments securely.
A work around I have used in the past is to have the search term collected using POST, parse the required URL for use with URI segments and then redirect your user to this page.
$url = 'mysite.com/search/' . urlencode($_POST['query']);
redirect($url);
This shouldn't effect SEO but something like the URL of a search result is unlikely to have any effect on SEO anyway. Clean URLs are only really meant to be used for permanent content. If you're going to be displaying the search term on the page, remember to use xss_clean(), seen a few people make this fatal mistake before.
I need a way to transfer a bunch of information (1-10kb) from an email in the Mail application to my iPhone app.
I was thinking I could craft a custom URL in the body of the email that, when clicked, would transfer the information through a custom URL handler to my app.
However, it's a lot of data. Can I pass that much data in the custom URL handler? e.g. myapp://load?var1=[lotsofdata]&var2=[lotsofdata]
Or, is there some better way I can transfer info from the Mail app to my app?
I don't know what the maximum length is, but I do know that you can have very long data-urls in Safari, which let you store image or other file data in the url itself. If the limits are similar, then you are in luck.
The usual limit for a GET should not be longer than 2083 characters to be on the safe side.
But also it should be a method to read the email directly from your own app, but I'm not very familiar with this solution.
Instead of a link in the email, you could probably just create a form that posts the information instead of sending a get request to your site; that would get around your length limitation (if there is one)
That last answer assumes you have a site to put the data on. If you're trying to keep things purely in email it would be nice to stick the data in the mail message. You can embed images in an email anyway, so why not?
Doing some research, I came across two blog posts that claim to have created large URLs that have worked, although one is using the data: URL scheme and the other is using mailto: .
Your best bet is to probably just try it out: Create a link using myapp:// with a large amount of data, stick it in an email and see if your app reads the entire thing.