Jump to content

set Geolocation curl_init(mock locations)


ChadGregory

Recommended Posts

ok I developing a plugin for wordpress and I need to be able to set the location to US, so that when it grabs product information the page that is being requested it brings in US dollars. Currently it is bringing in prices as Yen.

<?php
if (!function_exists('bb_file_contents')) {
	function bb_file_contents($url) {
		if(function_exists('curl_init')) {
			$ch = curl_init();
			$timeout = 0; // set to zero for no timeout
			
			curl_setopt ($ch, CURLOPT_URL, $url);
			curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
			curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, TRUE);
	
			$file_contents = curl_exec($ch);
	
			if (!$file_contents) {
				print_r(curl_getinfo($ch));
				die;
			}
	
			curl_close($ch);
		}
		
		else {
			$file_contents = file_get_contents($url);
		}
		
		return $file_contents;
	}
}
?>

Anyway of doing this? Or is there another way I can get the pages content for me to preg_match?

Link to comment
Share on other sites

do a simple math conversion on the price, then output it by multiplying the conversion rate.

 

I guess I forgot to mention that it would be just the price that would be affected but also the language as well.

 

But its not just the price actually its the actual name of the product to that could change, In the example of Yen as the currency Chinese is the language which would render the whole thing useless. For that I would have to have some way to auto detect the language and translate accordingly, or mock the geolocation of the requestion.

 

But as well this is a plugin for wordpress that could be on a server in any part of the world, so the currency and language would change. 

 

I need a in-plugin solution to take this problem out of the equation. Even if you know of a way that use Javascript or java to retrieve the info without geolocation that can send the data to PHP would work as well.

 

But again I have the question how?

Edited by ChadGregory
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

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