0

I asked this in a comment to the accepted answer to this question, but perhaps since it was a comment on an old question, and perhaps because the answer is obvious to anyone who's sure of it, it got no response. But I just wanted to get sure... I see countless examples of code accessing google maps api through php curl, where this is specified:

curl_setopt($ch, CURLOPT_PROXYPORT, 3128);

And yet there is no CURLOPT_PROXY specified or mentioned. To me, that makes no sense. So I think it's just a case where someone removed the proxy line from some sample code they had before posting it, and everyone else has blindly copy-pasted it into their code and then posted that code.

Can anyone confirm that? And if it's the case that the CURLOPT_PROXY line was omitted, does anyone know the significance of port 3128? I don't see that port number mentioned anywhere else other than in similar code snippets using google maps.

Community
  • 1
  • 1
sootsnoot
  • 2,178
  • 3
  • 22
  • 27
  • As a meta-question, I couldn't figure out how to make a link directly to a specific answer to a question, so I just linked to the question and said "the accepted answer to". Seems like there must be a way to do it, but I haven't found one. – sootsnoot Jun 13 '15 at 13:39

1 Answers1

0

Apparently,

Port 3128 is usually used by 'squid', a very popular web proxy server that is also able to proxy other protocols (e.g. ftp).

According to Wikipedia, Squid:

has a wide variety of uses, from speeding up a web server by caching repeated requests; to caching web, DNS and other computer network lookups for a group of people sharing network resources; to aiding security by filtering traffic.

So it seems like it isn't just an arbitrary port number.

In the future, you can link to a specific answer by clicking "share" under the answer and copying the link. For example, the link for the answer you were referring to would be https://stackoverflow.com/a/11395547/4241842.

Community
  • 1
  • 1
not_a_bot
  • 2,332
  • 2
  • 19
  • 33
  • Thanks for the tip about share - I guess I was thinking it would actively post something rather than give a permalink to copy-paste! I'd like to accept your answer, but it only addresses part of the question. Does the CURLOPT_PROXYPORT have any purpose if CUROPT_PROXY (i.e. the server) is not also specified? Is there some sort of curl default that makes it useful, or is CURLOPT_PROXYPORT really just a useless vestige carried along from original code that used a squid proxy server? -Thx – sootsnoot Jun 17 '15 at 22:02
  • Every other Google Maps curl example I saw, people used port 3218 without setting a proxy server. After reading more on [CURLOPT_URL](http://curl.haxx.se/libcurl/c/CURLOPT_URL.html), I found that `the host part of the URL contains the address of the server that you want to connect to`. My best guess is that since the URL they specify for geocoding (http://maps.google.com/maps/api/geocode/...) makes a call to Google, which in turn [makes a call to an external server](https://developers.google.com/maps/documentation/javascript/geocoding), you don't have to set up your own proxy server. – not_a_bot Jun 18 '15 at 21:24
  • I appreciate the response, but I can't say that I agree (or maybe I just don't understand what you mean). CURLOPT_URL specifies the destination url, it is the only *required* option when using curl. Reading the documentation for both [CURLOPT_PROXYPORT](http://curl.haxx.se/libcurl/c/CURLOPT_PROXYPORT.html) and [CURLOPT_PROXY](http://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html), it seems clearer to me than ever that CURLOPT_PROXYPORT without a CURLOPT_PROXY makes no sense. OTOH, CURLOPT_PROXY can specify a port number, rendering CURLOPT_PROXYPORT completely unnecessary. So no answer yet. – sootsnoot Jun 20 '15 at 00:37
  • Oddly enough, while your comment about "every other Google Maps curl example" matches what prompted me to ask this question, just now I did some more googling and quickly found several examples that do not use the CURLOPT_PROXYPORT option at all. So I'm thinking it really is a sloppy copy-paste explosion that caused the option to appear without a matching CURLOPT_PROXY in many posts around the web. – sootsnoot Jun 20 '15 at 00:49