Ver Mensaje Individual
  #2 (permalink)  
Antiguo 18/04/2016, 02:33
Avatar de Patriarka
Patriarka
 
Fecha de Ingreso: enero-2011
Ubicación: Moreno, Buenos Aires, Argentina
Mensajes: 2.851
Antigüedad: 13 años, 3 meses
Puntos: 288
Respuesta: como usar REST API ?

bueno estuve investigando y al parecer se puede hacer un poco mas facil lo que necesito:

Código PHP:
Ver original
  1. $token = "t1THTjfWv_S1iY5rTsaTBqRB-jsejs62pQjBY_ZiKeCBejgI0gcbpTBP8nJs3dVdvLfUzFEVnZosOU6JVuJeDhGCxbpu_JiC4rJmZ2sktQVFmq0Vv_J18yT44zuSZ1GQYIhkR06GEIH6pJcl3xZ-EQ..";
  2.  
  3. $url = 'https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/submitJob?token='.$token.'&orders={"features":[{"geometry":{"x":-122.51,"y":37.7724},"attributes":{"DeliveryQuantities":1706,"Name":"Store_1","ServiceTime":25,"TimeWindowStart1":1355245200000,"TimeWindowEnd1":1355274000000,"MaxViolationTime1":0}},{"geometry":{"x":-122.4889,"y":37.7538},"attributes":{"DeliveryQuantities":1533,"Name":"Store_2","ServiceTime":23,"TimeWindowStart1":1355245200000,"TimeWindowEnd1":1355274000000,"MaxViolationTime1":0}},{"geometry":{"x":-122.4649,"y":37.7747},"attributes":{"DeliveryQuantities":1580,"Name":"Store_3","ServiceTime":24,"TimeWindowStart1":1355245200000,"TimeWindowEnd1":1355274000000,"MaxViolationTime1":0}},{"geometry":{"x":-122.4739,"y":37.7432},"attributes":{"DeliveryQuantities":1289,"Name":"Store_4","ServiceTime":20,"TimeWindowStart1":1355245200000,"TimeWindowEnd1":1355274000000,"MaxViolationTime1":0}},{"geometry":{"x":-122.4493,"y":37.7315},"attributes":{"DeliveryQuantities":1302,"Name":"Store_5","ServiceTime":21,"TimeWindowStart1":1355245200000,"TimeWindowEnd1":1355274000000,"MaxViolationTime1":0}},{"geometry":{"x":-122.4917,"y":37.6493},"attributes":{"DeliveryQuantities":1775,"Name":"Store_6","ServiceTime":26,"TimeWindowStart1":1355245200000,"TimeWindowEnd1":1355274000000,"MaxViolationTime1":0}},{"geometry":{"x":-122.4832,"y":37.7012},"attributes":{"DeliveryQuantities":1014,"Name":"Store_7","ServiceTime":17,"TimeWindowStart1":1355245200000,"TimeWindowEnd1":1355274000000,"MaxViolationTime1":0}},{"geometry":{"x":-122.5301,"y":37.8935},"attributes":{"DeliveryQuantities":1761,"Name":"Store_8","ServiceTime":26,"TimeWindowStart1":1355245200000,"TimeWindowEnd1":1355274000000,"MaxViolationTime1":0}},{"geometry":{"x":-122.2875,"y":37.8909},"attributes":{"DeliveryQuantities":1815,"Name":"Store_9","ServiceTime":27,"TimeWindowStart1":1355245200000,"TimeWindowEnd1":1355274000000,"MaxViolationTime1":0}}]}&depots={"features":[{"geometry":{"x":-122.3943,"y":37.7967},"attributes":{"Name":"San Francisco","TimeWindowStart1":1355241600000,"TimeWindowEnd1":1355274000000}}]}&routes={"features":[{"attributes":{"Name":"Truck_1","StartDepotName":"San Francisco","EndDepotName":"San Francisco","StartDepotServiceTime":60,"EarliestStartTime":1355241600000,"LatestStartTime":1355241600000,"Capacities":"15000","CostPerUnitTime":0.2,"CostPerUnitDistance":1.5,"MaxOrderCount":2,"MaxTotalTime":360,"MaxTotalTravelTime":120,"MaxTotalDistance":80}},{"attributes":{"Name":"Truck_2","StartDepotName":"San Francisco","EndDepotName":"San Francisco","StartDepotServiceTime":60,"EarliestStartTime":1355241600000,"LatestStartTime":1355241600000,"Capacities":"15000","CostPerUnitTime":0.2,"CostPerUnitDistance":1.5,"MaxOrderCount":2,"MaxTotalTime":360,"MaxTotalTravelTime":120,"MaxTotalDistance":80}},{"attributes":{"Name":"Truck_3","StartDepotName":"San Francisco","EndDepotName":"San Francisco","StartDepotServiceTime":60,"EarliestStartTime":1355241600000,"LatestStartTime":1355241600000,"Capacities":"15000","CostPerUnitTime":0.2,"CostPerUnitDistance":1.5,"MaxOrderCount":2,"MaxTotalTime":360,"MaxTotalTravelTime":120,"MaxTotalDistance":80}}]}&time_units=Minutes&distance_units=Miles&uturn_policy=NO_UTURNS&populate_directions=true&directions_language=en&default_date=1355212800000&f=json';

Notar que los parametros: orders,depots y routes son json's

cuando ejecuto este codigo me da SCREAM: Error suppression ignored for

como podria parsear bien esta url?

Código PHP:
Ver original
  1. $app_info = file_get_contents($url);
  2. $app_info = json_decode($app_info, true);
  3. echo '<pre>';
  4. print_r($url);
  5. var_dump($app_info);
  6. echo '</pre>';