Jump to content

curl isn't responding the same on different hosts


Recommended Posts

I've been puzzling over this for a few days now, and the Siteground L2 support isn't willing to help out here.


I'm coding a Wordpress plugin to get affiliate tracking links from Tune/HasOffers. This is totally acceptable behavior AFAIK, and all I have to do is call a URL, and I'll be redirected to a landing page with whatever parm values I've specified.


I have a development Linode, where this script works as expected. You can see the output here: http://new.burtlo.info/wp-content/plugins/lmpostback/test.php


I've installed that same script on Siteground, but I get a zero length response: http://launchmoxie.com/wp-content/plugins/lmpostback/test.php


I've tried a number of variations on making the call, and have tried a number of curl options as well. I'm still stuck.


Any suggestions? Thanks in advance.


Here's the code:

$aff_link = 'http://jump.launchmoxie.com/aff_c?offer_id=26&aff_id=793';

// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $aff_link);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);

// grab URL and pass it to the browser
$response = curl_exec($ch);
print_r ($response);

echo 'strlen of response = ' . strlen($response);

// close cURL resource, and free up system resources
Link to comment
Share on other sites

curl_getinfo() on the server that doesn't work as expected gives me this:

Array ( [url] => http://jump.launchmoxie.com/aff_c?offer_id=26&aff_id=793 [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0 [namelookup_time] => 0 [connect_time] => 0 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 [starttransfer_time] => 0 [redirect_time] => 0 [redirect_url] => [primary_ip] => [certinfo] => Array ( ) [primary_port] => 0 [local_ip] => [local_port] => 0 )

curl_getinfo() on the server where it does behave as expected gives me this:

Array ( [url] => http://jump.launchmoxie.com/aff_c?offer_id=26&aff_id=793 [content_type] => text/html; charset=iso-8859-1 [http_code] => 302 [header_size] => 1089 [request_size] => 87 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.030762 [namelookup_time] => 0.004267 [connect_time] => 0.006786 [pretransfer_time] => 0.006869 [size_upload] => 0 [size_download] => 513 [speed_download] => 16676 [speed_upload] => 0 [download_content_length] => 513 [upload_content_length] => 0 [starttransfer_time] => 0.030703 [redirect_time] => 0 [redirect_url] => http://new.burtlo.info/optin-test?offer_id=26&offer_name=LaunchMoxie+Postback+Test&offer_ref=&goal_id={goal_id}&affiliate_id=793&affiliate_name=Burt+Lo&affiliate_ref=&source=&offer_url_id=0&transaction_id=102898cf11d15f4d0a8dfddd673e1c&session_ip=&ip= [primary_ip] => [certinfo] => Array ( ) [primary_port] => 80 [local_ip] => [local_port] => 48378 )
Edited by BurtLo
Link to comment
Share on other sites

Yes!!! That was it! It said that it couldn't resolve my URL.


That's a bit odd to me since my DNS is managed at Cloudflare, and I did have a valid CNAME record for that host.


I ended up adding the same CNAME alias in my Siteground DNS settings. My code worked immediately after that.


Thank you all for your help!!!

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.