Days ago I´m had a problem with the file_get_contents
, because the server has the rule allow_url_fopen=0
I´ve tried to change that by making a php.ini with allow_url_fopen=1
, but its not working. This is the part of the code that has the issue:
if($state == 5)
{
$request_services=RequestServices::where('request_id', $current_request->id)->first();
$address = urlencode(Input::get('address'));
$end_address = json_decode(file_get_contents("https://maps.googleapis.com/maps/api/geocode/json?address=$address"),TRUE);
$end_location = $end_address['results'][0]['geometry'];
$latitude = $end_location['location']['lat'];
$longitude = $end_location['location']['lng'];
$request_id = $current_request->id;
$walk_location_last = WalkLocation::where('request_id',$request_id)->orderBy('created_at','desc')->first();
if($walk_location_last)
{
$distance_old = $walk_location_last->distance;
$distance_new = distanceGeoPoints($walk_location_last->latitude,$walk_location_last->longitude,$latitude,$longitude);
$distance = $distance_old + $distance_new;
$settings = Settings::where('key','default_distance_unit')->first();
$unit = $settings->value;
$distance = $distance;
}
else{
$distance = 0;
}
The error is in this line:
$end_address = json_decode(file_get_contents("https://maps.googleapis.com/maps/api/geocode/json?address=$address"),TRUE);
It is calling file_get_contents with a google maps page url. I´m having a really hard time trying to change it to cURL with on what a have read is the correct and the best choice. Can you please help me by making this code to work as cURL.
Thanks in advance. I´m attaching a screen shot of the debug mode of the page