Can someone tell me how to create a QR code for a url with parameters - url

I've tried using a few web pages to create QR code to create a QR for a regular url and they fine.
However, if I had parameters to the url, the resulting url does not decode properly.
If you try this
http://chart.apis.google.com/chart?cht=qr&chs=500x500&choe=UTF-8&chld=H&chl=http://localhost?someparam=1&someotherparam=2
instead of the QR code pointing to http://localhost?someparam=1&someotherparam=2
the Barcodescanner decoder apps on Android and iPhone point to
http://localhost/?someparam=1&someotherparam=2
The forward slash / between what would be the server name (domain name) and the start of the parameter string is obviously incorrect.
I'm assuming that it's something to do with url encoding and I'm just looking for a pointer in the right direction from someone who might had already cracked this nut.
Zxing's QR code generator has the same effect. But it seems to rely on Google also.
http://zxing.appspot.com/generator/
Also
http://d-project.googlecode.com/svn/trunk/misc/qrcode/js/sample.html

You need to URL-encode each parameter value, in your example, the chl parameter in particular. Most languages have libraries for this these days or a web search for "url encoder " will give you a form.
The url encoding of http://localhost?someparam=1&someotherparam=2 is http%3A%2F%2Flocalhost%3Fsomeparam%3D1%26someotherparam%3D2.
Also, any parameter values to a URL that is itself a parameter value have to be independently URL encoded as well.
As Sean mentions below, if you enter your URL into the form on the appspot page, it correctly URL encodes the chart url:
http://chart.apis.google.com/chart?cht=qr&chs=350x350&chld=L&choe=UTF-8&chl=http%3A%2F%2Flocalhost%3Fsomeparam%3D1%26someotherparam%3D
I'm not sure about your extra / comment. If you go to the URL you give, the code value is
http://localhost?someparam=1
which is what is expected because the chl parameter value is not escaped and therefore ends at the first &.

Related

What is si=a or si=fc, etc in my soundcloud link? [duplicate]

https://www.airbnb.com/help?audience=host?audience=guest?audience=host?audience=host?audience=host
The URL above was created occasionally by me.
A normal URL to me has one question mark while all parameters are distinct. So in my opinion, this URL is abnormal.
What seems weird to me is that it still works and my browser has no complaint about it.
Would anyone explain it to me?
The first ? indicates the query component. The query component is terminated by the first following #, or the end of the URL.
So, this is the query component of your URL:
audience=host?audience=guest?audience=host?audience=host?audience=host
Within the query component, it’s perfectly fine to use ? characters, they don’t have any special meaning there (list of all allowed characters in the query).
While parameters in the query typically are in the name=value format, separated by &, this is just a convention (it’s what the encoding type application/x-www-form-urlencoded in HTML forms produces). Site authors can use whatever format they want.

how to pass special character (e.g. %) through url for create new event in google calendar

I am creating a new event in google calendar by the following URL structure.
https://calendar.google.com/calendar/r/eventedit?
text=discount for Asgardian&
dates=20200327T032400Z/20200327T032400Z&
details=Thor will be there to receive you&
location=Asgard&
trp=false&sprop=&sprop=name:
here is a URL variable text, which represents the title of an event.
if I pass a plain string, it works well. but if I pass special character like '%' (e.g. 20% off for Asgardian), then google calendar gave me -
Bad Request
Error 400
how can I pass '%'?
(same error for details vaiable also)
in the comment, #terry gave me answer for how to pass % through URL.
I need to encode it as %25.
he also share that - Javascript has a built-in function for this URL encoding. encodeURIComponent()
if we wrap our string by encodeURIComponent(), it'll give us URL encoded string.
thanks.

Static map api url with polyline gets uriEncoded from cordova file transfer plugin

I've got a url that if you copy and paste into your browser shows a map:
https://maps.googleapis.com/maps/api/staticmap?&key=AIzaSyAzijDqcmwhL7jvqZ625ZfjU-WskiuVqko&size=1000x900&path=weight:12|color:0x037AFF|enc:c`sfEl~`jUzAkf#{_#aKuhAnMhBjiAkpB|nB_rAxaCooCto#esBzAkyAf|#o{AhpAsrAlS{bAZeiEej#kzC_UgfAx|#_zA~g#goDl\yyEvaAwsBlnAo_Bdp#irBr}#}kEz|#uyH~}DodF|iBooDnlCgj#trAe{CjiBggArxAowAzdAskGfsFy{AdoB}aAjVivG|gKevAp|CwsA~~B{}E`cCgrBnvCsmBf`E_Zla#ooAeh#ccAsq#ibA_BqeCz|#{Vn\_u#z#ieCcGinDiGoz#nb#ak#`{A_`AdiBwmCfdCcqEt|Cw`Cj|AitCxaCkeBpsCcqAtjD_rAbxBqxDh~CksGfdH}dFn}LiaGxbLekEv`Da`CvgCceC`bB}qCzpCo}#~sC}r#~qDsp#tm#uwA_d#wmDpd#{bDnmEep#nrAm{#bb#}cDjn#cf#|w#uwB`oBi{BxtC}oBloBox#bdAuHvfAoV|iB}hAnkDajGx}F{wGtfH{m#hZol#jzAirBbbEc}F|rBw|CthA{cAv|#iv#j|As`Avh#ylDeDkyF`fE_gC|gBi`BveBovAdmBaeBvuAqxAHuuAb\kyApyAsIjz#yl#t}#_|Btt#c_AliAcoBnlBmtA`f#yzCjWwqDqPohAnh#aoCx{Esa#duEsqAlmA_xCoeCcaD`gBaxBbzBin#p_A}y#tlAiqA`FsqBx#goB~z#s|JntBs}AjbAg_EbfEup]lj`#ssObvPagHnrKotI||MweThm[edJzcKkfHfwGc`ElnCuyP|gLihVtuP{mT`mTu{HdvIa_CjoEkvBpqEwtEbvHsqEl_EwwIfzHyoEnfCmzKfbGcrDjvBufF`oEsuKljJscPhoNkuG~~HiqN|rSuiRliNa`VryN{xLlcIaxKrqMw}Np{MmTpOePfxOkoCvyFky#zlC_lAh~#vj#dmCp_AhhAfOjrDlk#|uAbt#dn#phBbeGri#nh##dz#cKhnAvn#~z#pa#hgDpyBx}Bxs#zgDrtA`{Ajn#vMrg#cRxs#rJrXfu#lYdhAgaAnrBaMlnAwu#l]e]b~AdPru#mA`vBizB~jDy\`d#hi#r^bWfYc[pyBmGjjAyrJpxDwwEdsBs|BzaCkqEpbDsmBlpBm|B`lCuqD|xF}qEn|ImmAxlAsoBvn#qxB~m#yeBpbBcrC`mCcbB|gB{\hhDaz#~aDm`ErrWcq#`iDmeCfqDqzDbuFkeCh~F_o#pzE_d#~eBoqBlaCujGfhGmfD|dEuOvcDspBtjDcf#nk#_G{n#sKcQ&markers=color:0xFF8F00%7Clabel:A%7C32.70735640000002,-117.1564884&markers=color:0xFF8F00%7Clabel:B%7C37.62131290000001,-122.37895540000005&style=feature:landscape|hue:0xFFBB00|saturation:43.400000000000006|lightness:37.599999999999994|gamma:1&style=feature:road|hue:0xFFC200|saturation:-61.8|lightness:45.599999999999994|gamma:1&style=feature:road|hue:0xFF0300|saturation:-100|lightness:51.19999999999999|gamma:1&style=feature:road|hue:0xFF0300|saturation:-100|lightness:52|gamma:1&style=feature:water|hue:0x0078FF|saturation:-13.200000000000003|lightness:2.4000000000000057|gamma:1&style=feature:poi|hue:0x00FF6A|saturation:-1.0989010989011234|lightness:11.200000000000017|gamma:1
but when I pass this url into the $cordovaFileTransfer.download method, it runs encodeURI internally which then coverts the url to:
https://maps.googleapis.com/maps/api/staticmap?&key=AIzaSyAzijDqcmwhL7jvqZ625ZfjU-WskiuVqko&size=1000x900&path=weight:12%7Ccolor:0x037AFF%7Cenc:c%60sfEl~%60jUzAkf#%7B_#aKuhAnMhBjiAkpB%7CnB_rAxaCooCto#esBzAkyAf%7C#o%7BAhpAsrAlS%7BbAZeiEej#kzC_UgfAx%7C#_zA~g#goDl%5CyyEvaAwsBlnAo_Bdp#irBr%7D#%7DkEz%7C#uyH~%7DDodF%7CiBooDnlCgj#trAe%7BCjiBggArxAowAzdAskGfsFy%7BAdoB%7DaAjVivG%7CgKevAp%7CCwsA~~B%7B%7DE%60cCgrBnvCsmBf%60E_Zla#ooAeh#ccAsq#ibA_BqeCz%7C#%7BVn%5C_u#z#ieCcGinDiGoz#nb#ak#%60%7BA_%60AdiBwmCfdCcqEt%7CCw%60Cj%7CAitCxaCkeBpsCcqAtjD_rAbxBqxDh~CksGfdH%7DdFn%7DLiaGxbLekEv%60Da%60CvgCceC%60bB%7DqCzpCo%7D#~sC%7Dr#~qDsp#tm#uwA_d#wmDpd#%7BbDnmEep#nrAm%7B#bb#%7DcDjn#cf#%7Cw#uwB%60oBi%7BBxtC%7DoBloBox#bdAuHvfAoV%7CiB%7DhAnkDajGx%7DF%7BwGtfH%7Bm#hZol#jzAirBbbEc%7DF%7CrBw%7CCthA%7BcAv%7C#iv#j%7CAs%60Avh#ylDeDkyF%60fE_gC%7CgBi%60BveBovAdmBaeBvuAqxAHuuAb%5CkyApyAsIjz#yl#t%7D#_%7CBtt#c_AliAcoBnlBmtA%60f#yzCjWwqDqPohAnh#aoCx%7BEsa#duEsqAlmA_xCoeCcaD%60gBaxBbzBin#p_A%7Dy#tlAiqA%60FsqBx#goB~z#s%7CJntBs%7DAjbAg_EbfEup%5Dlj%60#ssObvPagHnrKotI%7C%7CMweThm%5BedJzcKkfHfwGc%60ElnCuyP%7CgLihVtuP%7BmT%60mTu%7BHdvIa_CjoEkvBpqEwtEbvHsqEl_EwwIfzHyoEnfCmzKfbGcrDjvBufF%60oEsuKljJscPhoNkuG~~HiqN%7CrSuiRliNa%60VryN%7BxLlcIaxKrqMw%7DNp%7BMmTpOePfxOkoCvyFky#zlC_lAh~#vj#dmCp_AhhAfOjrDlk#%7CuAbt#dn#phBbeGri#nh##dz#cKhnAvn#~z#pa#hgDpyBx%7DBxs#zgDrtA%60%7BAjn#vMrg#cRxs#rJrXfu#lYdhAgaAnrBaMlnAwu#l%5De%5Db~AdPru#mA%60vBizB~jDy%5C%60d#hi#r%5EbWfYc%5BpyBmGjjAyrJpxDwwEdsBs%7CBzaCkqEpbDsmBlpBm%7CB%60lCuqD%7CxF%7DqEn%7CImmAxlAsoBvn#qxB~m#yeBpbBcrC%60mCcbB%7CgB%7B%5ChhDaz#~aDm%60ErrWcq#%60iDmeCfqDqzDbuFkeCh~F_o#pzE_d#~eBoqBlaCujGfhGmfD%7CdEuOvcDspBtjDcf#nk#_G%7Bn#sKcQ&markers=color:0xFF8F00%257Clabel:A%257C32.70735640000002,-117.1564884&markers=color:0xFF8F00%257Clabel:B%257C37.62131290000001,-122.37895540000005&style=feature:landscape%7Chue:0xFFBB00%7Csaturation:43.400000000000006%7Clightness:37.599999999999994%7Cgamma:1&style=feature:road%7Chue:0xFFC200%7Csaturation:-61.8%7Clightness:45.599999999999994%7Cgamma:1&style=feature:road%7Chue:0xFF0300%7Csaturation:-100%7Clightness:51.19999999999999%7Cgamma:1&style=feature:road%7Chue:0xFF0300%7Csaturation:-100%7Clightness:52%7Cgamma:1&style=feature:water%7Chue:0x0078FF%7Csaturation:-13.200000000000003%7Clightness:2.4000000000000057%7Cgamma:1&style=feature:poi%7Chue:0x00FF6A%7Csaturation:-1.0989010989011234%7Clightness:11.200000000000017%7Cgamma:1
To see one of the differences, look at the param &path=weight:12. Right after, you'll see the | character in the first string is encoded to %7C in the second string. The problem is that this encoded url gets a 404 on the Google Static Maps API.
Should the $cordovaFileTransfer.download have an option to NOT encode urls or is there some param I should be passing along with the URL to the Google Static Maps API that tells it to decode it?
UPDATE
I believe the issue isn't with encoding or anything like that but with the length of the encoded url. I tried removing the &markers param (and everything after) and it worked.
https://maps.googleapis.com/maps/api/staticmap?&key=AIzaSyAzijDqcmwhL7jvqZ625ZfjU-WskiuVqko&size=1000x900&path=weight:12%7Ccolor:0x037AFF%7Cenc:c%60sfEl~%60jUzAkf#%7B_#aKuhAnMhBjiAkpB%7CnB_rAxaCooCto#esBzAkyAf%7C#o%7BAhpAsrAlS%7BbAZeiEej#kzC_UgfAx%7C#_zA~g#goDl%5CyyEvaAwsBlnAo_Bdp#irBr%7D#%7DkEz%7C#uyH~%7DDodF%7CiBooDnlCgj#trAe%7BCjiBggArxAowAzdAskGfsFy%7BAdoB%7DaAjVivG%7CgKevAp%7CCwsA~~B%7B%7DE%60cCgrBnvCsmBf%60E_Zla#ooAeh#ccAsq#ibA_BqeCz%7C#%7BVn%5C_u#z#ieCcGinDiGoz#nb#ak#%60%7BA_%60AdiBwmCfdCcqEt%7CCw%60Cj%7CAitCxaCkeBpsCcqAtjD_rAbxBqxDh~CksGfdH%7DdFn%7DLiaGxbLekEv%60Da%60CvgCceC%60bB%7DqCzpCo%7D#~sC%7Dr#~qDsp#tm#uwA_d#wmDpd#%7BbDnmEep#nrAm%7B#bb#%7DcDjn#cf#%7Cw#uwB%60oBi%7BBxtC%7DoBloBox#bdAuHvfAoV%7CiB%7DhAnkDajGx%7DF%7BwGtfH%7Bm#hZol#jzAirBbbEc%7DF%7CrBw%7CCthA%7BcAv%7C#iv#j%7CAs%60Avh#ylDeDkyF%60fE_gC%7CgBi%60BveBovAdmBaeBvuAqxAHuuAb%5CkyApyAsIjz#yl#t%7D#_%7CBtt#c_AliAcoBnlBmtA%60f#yzCjWwqDqPohAnh#aoCx%7BEsa#duEsqAlmA_xCoeCcaD%60gBaxBbzBin#p_A%7Dy#tlAiqA%60FsqBx#goB~z#s%7CJntBs%7DAjbAg_EbfEup%5Dlj%60#ssObvPagHnrKotI%7C%7CMweThm%5BedJzcKkfHfwGc%60ElnCuyP%7CgLihVtuP%7BmT%60mTu%7BHdvIa_CjoEkvBpqEwtEbvHsqEl_EwwIfzHyoEnfCmzKfbGcrDjvBufF%60oEsuKljJscPhoNkuG~~HiqN%7CrSuiRliNa%60VryN%7BxLlcIaxKrqMw%7DNp%7BMmTpOePfxOkoCvyFky#zlC_lAh~#vj#dmCp_AhhAfOjrDlk#%7CuAbt#dn#phBbeGri#nh##dz#cKhnAvn#~z#pa#hgDpyBx%7DBxs#zgDrtA%60%7BAjn#vMrg#cRxs#rJrXfu#lYdhAgaAnrBaMlnAwu#l%5De%5Db~AdPru#mA%60vBizB~jDy%5C%60d#hi#r%5EbWfYc%5BpyBmGjjAyrJpxDwwEdsBs%7CBzaCkqEpbDsmBlpBm%7CB%60lCuqD%7CxF%7DqEn%7CImmAxlAsoBvn#qxB~m#yeBpbBcrC%60mCcbB%7CgB%7B%5ChhDaz#~aDm%60ErrWcq#%60iDmeCfqDqzDbuFkeCh~F_o#pzE_d#~eBoqBlaCujGfhGmfD%7CdEuOvcDspBtjDcf#nk#_G%7Bn#sKcQ
What's interesting is that I've read there is a 2048 character limit on urls for the Google Maps API. The first url above is 2096 characters and the second is 2387 characters. I'm kind of stumped as to why the first one worked at all...

What does "URL=" in a URL Mean?

May be a dumb question, but it's been bugging me recently. I see "URL=" inside alot of URL's, such as this one:
http://www.tierraantigua.com/search-2?url=http%3A%2F%2Flink.flexmls.com%2Fwws30ham
What exactly is this used to do? Is it part of the iFrame functionality? I know the last part of the URL (after the URL=) is the part being displayed in the iFrame, but I'm unsure of why it is included in the primary URL as well.
Thanks!
The url you see here is just a standard query parameter wit the name url and the encoded value http%3A%2F%2Flink.flexmls.com%2Fwws30ham which decodes to http://link.flexmls.com/Fwws30ham. Most of the times it is used for determining redirection or source information by the application you are using. It is entirely domain-specific and can have any meaning the website developer would like to use.
PHP GET
Description ¶
An associative array of variables passed to the current script via the URL parameters.
$url = $_GET['url'];
echo $url; // http%3A%2F%2Flink.flexmls.com%2Fwws30ham

is there a simple way to get URL in java

I am working on an email validation link for a website. When a user registers and finishes filling in their personal data (and it passes all the checks), they are sent to a jsp page saying that an email has been sent to the address they entered as the username, with a link to click to validate the email address. So that part is all well and good, I generate the link (for now just using my localhost) and it looks like this as an example http://localhost:9999/javawork/msc/validate/?6FRQ8RAT&u=1s3w1Iih64egX01188HT. When they click the link it goes to the jsp page index.jsp in the validation folder. At this point I need to grab the entire URL and send it to a function to make sure the URL is formatted properly (for security purposes). If it passes and the format is fine, I need to grab the 8 digit code immediately after the '?' and also the value of 'u'. I then send those values to a function that checks that they match what we have in our DB, and if they do, I update the DB record with a validation date so we know they have validated their email address.
So my question is first, how do I grab the entire URL to check the format, and second, how do I grab the 8 digit code, and the value of 'u'? I have been looking online and all examples require creating multiple functions or classes, and using the URL class. And they all want me to make an instance of a URL object and initialize it using the entire URL. But it is not a static URL, it will be different for every user that registers, as it generates a random 8 digit code to check against, and the value of 'u' is the masked user id from the DB. I don't understand how it can require you to initialize the entire URL in order to get the values, when you don't know what the values are until you get them from the URL.
Is there a simple way to grab the values, and the entire URL? Even if I can just get everything after the '?', I know the base URL and can build a new String to check the formatting if I can get from the '?' and after. Please help with that part. Thanks.
The Interface HTTPServletRequest contains a method getRequestURL which returns a StringBuffer which you may use to check the format of the entire URL.
You can get it, in a jsp page with :
<%=request.getRequestURL()%>
If you are using the format of request that you specified above, then your second question :
how do I grab the 8 digit code, and the value of 'u'?
May be answered by manipulating that StringBuffer to split at the ? and & for the 8 digit code.
Or use another request method,
ServletRequest.getParameter(java.lang.String name)
To grab each parameters, though, i'm not certain how it will end up handling the unnamed parameter of the 8 digit code. Let me know how that goes.
Don't think of the 8-digit code as an unnamed parameter. Think of it as a parameter without a value.
request.getParameterNames() will give you the 8-digit code as well as "u". So you can loop through like so:
String code = "";
for(String paramName : request.getParameterNames()) {
if(!paramName.equalsIgnoreCase("u"))
code = paramName;
}

Resources