I need to encode an url in javascript and decode it in php.. how can I do this? I tried using encodeURI and encodeURIComponent functions with urldecode in php but it doesnt work...
Encoding URLs in Javascript should work fine with encodeURI(). See here:
Encode URL in JavaScript?
In PHP, if the URL you're reading is being passed through a GET parameter, there's no need to decode it. It's already been done. Otherwise, urldecode() is your answer.
You're gonna need to post more info if you need more help.
Related
I'm using Bitly to shorten some URLs (which I have no control over), and the URLs are formatted like:
http://example.net?someParam=abc%2Fdef
Unfortunately, when I pass that URL to Bitly, the %2F gets URL decoded back to a /. I've checked through the documentation and I can't see any setting to preserve the encoding.
I've also tried encoding the % as %25 first, but Bitly seems to be selective in which encoded characters to decode - the %25 remains encoded.
Any ideas how to get around this or whether it's something Bitly can support?
Using this endpoint btw: https://api-ssl.bitly.com/v4/shorten
Is there any setting for url limit in Yii 2?
Some of my urls are over 300 characters and I get a 403 Forbidden code;
http://website/servicii-de-proiectare-asistenta-tehnica-din-partea-proiectantului-pe-perioada-derularii-lucrarilor-si-executie-de-lucrari-pentru-proiectul-%E2%80%9Emodernizare-drumuri-comunale-dc----dc----si-dc---a-de-pe-raza-comunei-lunca-judetul-boto-ani%E2%80%9D-863506-switch.html
If I shorten the url, it works.
this is my urlmanager rule:
'<title:(.*)>-<id:([0-9]+)>-access-not-granted.html' => 'member/licitatii/access-not-granted',
I tried to find some information regarding this issue and surprisingly enough, I didn't found a thing regarding URL length permitted.
However, I found a Yii way to solve your issue: Short URL Yii extension presented here - http://www.yiiframework.com/extension/google-url-shortener/
Also, please read this documentation that better explains how Yii treats URL routs: http://www.larryullman.com/2013/02/18/understanding-routes-in-the-yii-framework/
I know this does not solve your problem directly, but hope it gets you somewhere!
L.E: Here you have the bitly extension for Short URL's: http://www.yiiframework.com/extension/bitly-url-shortener/
Keep on coding,
Ares.
Why would that rule apply to your URL? From what I can see your URL will never trigger that rule.
I do not think there is a limit with the string of the URL in Yii2, try deleting some of the first part of the string to test this. try with an url like
http://website/proiectul-%E2%80%9Emodernizare-drumuri-comunale-dc----dc----si-dc---a-de-pe-raza-comunei-lunca-judetul-boto-ani%E2%80%9D-863506-switch.html
You might have problems because you have diacritics in the URL, try without them.
So, i have an url - http://somesite.com/#sometext. I need to shorten this url with the bit.ly API. The problem is, i cant properly escape the '#' symbol. I dont get any short url's if trying to short this one with the API. But i can simply short any other url's (without the '#').
The thing is i can properly shorten this url on bit.ly website and in TweetDeck (they using the API too, right?). But i cant manage to shorten it with the API.
Some suggestions?
Thanks you.
You can escape the URL fragment (#something) before sending it to bit.ly for shortening. URL fragment by definition won't leave the browser when submitted to the server. Escaping it allows it to go through. E.g. in Javascript, escUrl = encodeURIComponent(url) would do it.
What I'm trying to achieve is something similar to an Add-on called Live Http Headers used with Firefox. I'm not trying to get the Headers or cookies, but the links that load on the page itself. Let us assume I visited Mail.Yahoo.com, this is pretty much what you would see when I use the add-on.
CLICK HERE
How can I achieve something similar ? Only the links that load on the page itself !
I'm looking forward into reading your suggestions, please enlighten me if you know!
You can download the webpage using a webclient instance
Then with the result string, you can get the urls using a regular expression
http://www.geekzilla.co.uk/view2D3B0109-C1B2-4B4E-BFFD-E8088CBC85FD.htm
I am using the Yahoo Placemaker API and would like to send a request but I am getting confused as to how to send the request. The request is composed of a URL and a document and inside the document, there are a bunch of parameters. Please see below.
http://wherein.yahooapis.com/v1/document
documentContent=Sunnyvale+CA
documentType=text/plain
appid=my_appid
How do I format the URL into a request is it like so?
http://wherein.yahooapis.com/v1/documentContent=Sunnyvale+CA?documentType=text/plain?appid=my_appid
I would like to use this the Placemaker service for a Mac app written in objective-c.
Any suggestions would be great. Thanks.
You don't. The URI and the request body are different things.
It would be helpful if you explained why you're asking. What platform/API/language are you using?