BurtLo Posted August 31, 2015 Share Posted August 31, 2015 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: <?php $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 curl_close($ch); ?> Quote Link to comment https://forums.phpfreaks.com/topic/297992-curl-isnt-responding-the-same-on-different-hosts/ Share on other sites More sharing options...
scootstah Posted August 31, 2015 Share Posted August 31, 2015 What does curl_getinfo() give you? Quote Link to comment https://forums.phpfreaks.com/topic/297992-curl-isnt-responding-the-same-on-different-hosts/#findComment-1519957 Share on other sites More sharing options...
BurtLo Posted August 31, 2015 Author Share Posted August 31, 2015 (edited) 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=45.79.101.167&sale_amount=0.00 [primary_ip] => 52.8.61.250 [certinfo] => Array ( ) [primary_port] => 80 [local_ip] => 45.79.101.167 [local_port] => 48378 ) Edited August 31, 2015 by BurtLo Quote Link to comment https://forums.phpfreaks.com/topic/297992-curl-isnt-responding-the-same-on-different-hosts/#findComment-1519962 Share on other sites More sharing options...
ignace Posted August 31, 2015 Share Posted August 31, 2015 Run curl_error. Quote Link to comment https://forums.phpfreaks.com/topic/297992-curl-isnt-responding-the-same-on-different-hosts/#findComment-1519963 Share on other sites More sharing options...
BurtLo Posted August 31, 2015 Author Share Posted August 31, 2015 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!!! Quote Link to comment https://forums.phpfreaks.com/topic/297992-curl-isnt-responding-the-same-on-different-hosts/#findComment-1519965 Share on other sites More sharing options...
QuickOldCar Posted August 31, 2015 Share Posted August 31, 2015 I tested and saw both have a redirect, a 302 and a 301, you need to follow redirects now. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); Quote Link to comment https://forums.phpfreaks.com/topic/297992-curl-isnt-responding-the-same-on-different-hosts/#findComment-1519970 Share on other sites More sharing options...
BurtLo Posted September 1, 2015 Author Share Posted September 1, 2015 Yup, got it. I had set that to true during debugging, knowing I'd have to follow in the end. Thanks for following up with me. Quote Link to comment https://forums.phpfreaks.com/topic/297992-curl-isnt-responding-the-same-on-different-hosts/#findComment-1520049 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.