Jump to content
tz8

getting Banner with cURL

Recommended Posts

Hi fellow sysops,

i successfully set up the whole system and i do get my banners when i hit my url http://my.servername.de/adserver/www/delivery/avw.php?zoneid=1&cb=5623333122773&n=a83aca87 in multiple crowsers (IE, Edge, Chrome, Safari)

but when i hit the very same URL with cURL to save the banner to a file i only get the 1x1 gif in return.

i tried
curl -L "http://my.servername.de/adserver/www/delivery/avw.php?zoneid=1&cb=5623333122773&n=a83aca87"
curl -j -L "http://my.servername.de/adserver/www/delivery/avw.php?zoneid=1&cb=5623333122773&n=a83aca87"
curl -L --data-urlencoded "zoneid=1&cb=5623333122773&n=a83aca87http://my.servername.de/adserver/www/delivery/avw.php

and checking with
curl -v "http://my.servername.de/adserver/www/delivery/avw.php?zoneid=1&cb=5623333122773&n=a83aca87"
shows that i don't get the desired HTTP/302 with the new Location back but just the 1x1.gif

My guess is it bubbles down to this part of avw.php:

if ($row['default_banner_image_url'] != '') {
MAX_redirect($row['default_banner_image_url']);
} else {
MAX_commonDisplay1x1();
}

so the question is: Why is it working in browsers but fails in cURL? Any hint?


 

Share this post


Link to post
Share on other sites

further information:

here's the access.log when called from my browser:

x.x.x.x - - [29/Apr/2016:18:20:11 +0200] "GET /adserver/www/delivery/avw.php?zoneid=1&cb=5623333122773&n=a83aca87 HTTP/1.1" 302 1074 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2716.0 Safari/537.36"
x.x.x.x - - [29/Apr/2016:18:20:11 +0200] "GET /adserver/www/images/c8e870699b1cef591f057ecdb846ada6.jpg HTTP/1.1" 304 182 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2716.0 Safari/537.36"

and here's wget:

x.x.x.x - - [29/Apr/2016:18:21:31 +0200] "GET /adserver/www/delivery/avw.php?zoneid=1&cb=5623333122773&n=a83aca87 HTTP/1.1" 200 598 "-" "Wget/1.16 (linux-gnu)"

and here's cURL:

x.x.x.x - - [29/Apr/2016:18:30:51 +0200] "GET /adserver/www/delivery/avw.php?zoneid=1&cb=562356712521&n=a83aca86 HTTP/1.1" 200 542 "-" "curl/7.38.0"

and here's a more verbose output of curl:

user@host:~$ curl -vvv -L -c cookiejar "http://my.servername.de/adserver/www/delivery/avw.php?zoneid=1&cb=562356712521&n=a83aca86"
* Hostname was NOT found in DNS cache
*   Trying x.x.x.x...
* Connected to my.servername.de (x.x.x.x) port 80 (#0)
> GET /adserver/www/delivery/avw.php?zoneid=1&cb=562356712521&n=a83aca86 HTTP/1.1
> User-Agent: curl/7.38.0
> Host: my.servername.de
> Accept: */*

< HTTP/1.1 200 OK
< Date: Fri, 29 Apr 2016 16:43:02 GMT
* Server Apache/2.4.10 (Debian) is not blacklisted
< Server: Apache/2.4.10 (Debian)
< Pragma: no-cache
< Cache-Control: no-cache, no-store, must-revalidate
< Expires: 0
< Access-Control-Allow-Origin: *
* Added cookie OAID="f47bb8e275b37437fcb91658e928b342" for domain my.servername.de, path /, expire 1493484182
< Set-Cookie: OAID=f47bb8e275b37437fcb91658e928b342; expires=Sat, 29-Apr-2017 16:43:02 GMT; Max-Age=31536000; path=/
* Added cookie OAVARS[a83aca86]="a%3A2%3A%7Bs%3A8%3A%22bannerid%22%3Bs%3A0%3A%22%22%3Bs%3A6%3A%22zoneid%22%3Bs%3A1%3A%221%22%3B%7D" for domain my.servername.de, path /, expire 0
< Set-Cookie: OAVARS[a83aca86]=a%3A2%3A%7Bs%3A8%3A%22bannerid%22%3Bs%3A0%3A%22%22%3Bs%3A6%3A%22zoneid%22%3Bs%3A1%3A%221%22%3B%7D; path=/
< Content-Length: 43
< Content-Type: image/gif

* Connection #0 to host my.servername.de left intact
GIF89a����!�,D;

 

both wget and curl receive the 1x1.gif (see last line of the output above), just the browser actually gets the intended banner

anyone?

Share this post


Link to post
Share on other sites

just in case anyone needs this in the future - this doesn't seem to be a common problem around here based on the sheer amount of responses:

    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieJar);
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieJar);
    curl_setopt($ch, CURLOPT_REFERER, APP_URL.'/fancy_changing_fake_url_here/page/');

i managed to successfully get banners when i pass curl a cookiejar for the entire session and an always changing referrer

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




×
×
  • Create New...