Twitter share api doesnt get url with two # signs - twitter

want to share text and url like that:
test http://one#two#three
so i try
https://twitter.com/intent/tweet?text=test&url=http%3A%2F%2Fone%23two%23three
and get in result only "test" without the url
when in url is only one # sigh is ok
for example
https://twitter.com/intent/tweet?text=test&url=http%3A%2F%2Fone%23two
give me
test http://one#two
how to add sec #?

This is almost certainly because it is not correct syntax to have more than one # in a URL.
What sort of URL are you sharing that needs two?
If you absolutely have to, you can cheat and URL Encode the second % into %25
https://twitter.com/intent/tweet?text=test&url=http%3A%2F%2Fone%23two%2523two

Related

Add # hashtag before parameters in URL

I'm creating a dynamic website which is displaying many products. There are also filters like price (from - to), year (from-to) etc. I need to put # symbol before the filter parameters in URL because of Googlebot indexing. But I have no idea how to do it and found no documentation on the internet.
I think it could be done with AJAX script but I don't know where to start.
The question is:
How do I insert a # hash symbol before parameters in URL?
I've got this:
http://domain.com/pd/?rps=100&a=2001
and I need to make it look like
http://domain.com/pd/#rps=100&a=2001
Why do you want to replace the "?" with "#". For well optimised url to seo, you can leave them unchanged. You can also use Google Webmaster Tool to declare your url parameters. Here is another resource for you to optimize your url :Faceted navigation

Removing characters from a URL field

I have a user profile with an url field that shows their website. Right now it displays it like this: http://www.userwebsite.com
How can I remove the "http://www." part on my show.html.erb file, when displaying the user profile?
You can either play string games or you can use the URI module:
require 'uri'
url = URI.parse("http://www.userwebsite.com")
url.host.split(".")[-2..-1].join(".")
The advantage of doing it this way is that you know that you've only got the host at this point, not the scheme or any other noise, such as the post-host path, etc.
It's probably easier to just split the URL and do this stuff but you'll have more error handling and special case handling that way.

How does one escape the # sign in a Url pattern in UrlMappings.groovy?

In order to maintain the current set of Urls in a project, I have to be able to use the # (pound sign) in the Url. For some reason the pound sign does not appear to work normally in this project for UrlMappings.groovy.
Is there a special escape-sequence that must be used when placing # signs in UrlMappings.groovy?
Am I missing some reason why one cannot use pound signs at all?
In the following URL Mapping example, the browser goes to the correct page, but the pageName variable is null:
"/test/${urlName}#/overview"(controller:'test', action:'overview') {
pageName = "overview"
}
I thought everything after # in the url would be treated on the client side of the browsers where it tries to find a and scroll to that location.
If you dump the request containing the pound char, do you even see the data behind #?
I used a Named URL mapping and it works fine, no need to escape the "#" sign:
name test: "/#abc" (controller: 'test', action:'homepage')
EDIT: My above answer is wrong. In fact, it falls to a special case when homepage is the default action of the view.
Netbrain is right, the path after "#" will never be sent to server. In stead, I found that it's possible using "%23" instead of "#". Please take a look at here.
For example, instead of /test#/abc we should use /test%23/abc as URL mapping (both at client side & server side).

How can I parse the `access_token` from a Facebook callback URL?

This is the request Facebook calls back:
/facebook/promo/#access_token=162592277090170%7C2.yCch3otjrdit_rgBFS6F0A__.3600.1285369200-727781553%7CtugQmoO0bRiadumHVQrrSiPRD9Y&expires_in=7174
How can I parse the access_token from the URL? I could not find any way to get the access_token value.
Please be aware that it is not a reqular parameter.
You could use a Regex to match it out of the url. Or simply take everything as a sub-string between access_token= and the next &-character or the end of the url, which ever comes first.
I believe that it's not possible - the part after # is simply ignored. See this answer: Rails: Extracting the raw url from the request
If you're only after the access_token=... section, just use some simple string matching:
url = '/facebook/promo/#access_token=162592277090170%7C2.yCch3otjrdit_rgBFS6F0A__.3600.1285369200-727781553%7CtugQmoO0bRiadumHVQrrSiPRD9Y&expires_in=7174'
url[/#access_token=(.+)&/, 1]
=> "162592277090170%7C2.yCch3otjrdit_rgBFS6F0A__.3600.1285369200-727781553%7CtugQmoO0bRiadumHVQrrSiPRD9Y"
That looks for #access_token= and grabs everything up to &.

Can an URL shortener pass parameters?

I use bit.ly to shorten my urls.
My problem - paramters are not passed.
Let me explain I use http://bit.ly/MYiPhoneApps which redirects (let's say) to http://iphone.pp-p.net/default.aspx
Now when I try http://bit.ly/MYiPhoneApps?param=xx this param is not added to the resulting url.
I know I could create an extra "short url" including a paramter - so http://bit.ly/WithParam would result in http://www.mysite.com/somepath/apage.aspx?Par1=yy and so forth.
But what I want is to have a short URL directing to a page - and then I want to add a parameter to this shortened url - which shoul (of course) land at my page.
Is this a shortcome of bit.ly (and others are maybe able to do it) - or does "parameter forwarding" not work with 301 redirections?
Manfred
There's no technical reason why it couldn't be done. The service would simply have to look at what parameters it is being sent, and then rewrite the target URL accordingly.
The problem is that it's not necessarily well defined how to do that.
Suppose you have the url http://example.com/default.aspx?foo=bar, and it has the short url http://foo.com/ABCD. What should happen if you try to access http://foo.com/ABCD?foo=baz? Should it replace the value, so you get foo=baz? Should it append it to make foo=bar&foo=baz? If we include both, which order should they be in?
The system cannot know which parameters are safe to override and which are not, because sometimes, you DO want both of them in the URL, and it may matter what order things are added in.
You could argue "Well, just don't allow this for URLs where parameters are already present", but there's also the issue that it's going to complicate the process a lot more. Without this, you just lookup a key in a database and send a redirect header. Now, you need to also analyze the URL to check for parameters, and append part of the URL you were called by. That requires more system resources per redirect, which may become a big problem if your service is used very frequently - you'll need more server power to handle the same amount of redirects. I don't think that tradeoff is considered to be "worth it".
As mentioned in comments by rinogo and Jurgen
In Clickmeter
Destination URL : www.yoursite.com?myparam1={id1}&myparam2={id2}
Tracking link : www.go.clickmeter.com/38w2?id1=123&id2=abc
After click : www.yoursite.com?myparam1=123&myparam2=abc
In TinyUrl
Destination URL : http://x.com?a=1
Shorten URL : https://tiny url.com/y6gh7ovk
Shorten URL + param : https://tiny url.com/y6gh7ovk?a=2
Resultant URL : http://x.com/?a=1&a=2
Added space to post tinyurl
URL shortening associates a unique key based on a full URL (parameters and all), so it is not possible to pass parameters to a shortening service.
Typically
http://iphone.pp-p.net/default.aspx?param=10
must produce a different key to
http://iphone.pp-p.net/default.aspx?param=22
'Parameter forwarding' is simply not possible in these kinds of redirects, as parameters are not valid parts of a shortened URL is most (if not all) services.

Resources