Foros del Web » Programando para Internet » PHP »

url to json

Estas en el tema de url to json en el foro de PHP en Foros del Web. hola tengo usta url, observar que algunos parametros tiene un json adentro. si copia y pega esta url en su navegador devuelve un json: @import ...
  #1 (permalink)  
Antiguo 23/04/2016, 16:03
Avatar de Patriarka  
Fecha de Ingreso: enero-2011
Ubicación: Moreno, Buenos Aires, Argentina
Mensajes: 2.851
Antigüedad: 13 años, 3 meses
Puntos: 288
url to json

hola tengo usta url, observar que algunos parametros tiene un json adentro.
si copia y pega esta url en su navegador devuelve un json:

Código Javascript:
Ver original
  1. https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/submitJob?token=<yourToken>&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
y me devolveria este resultado:

{
"jobId": "jb1e9c0999ec047f4ac99750055041719",
"jobStatus": "esriJobSubmitted"
}

pero necesito procesar esta url con php

Código PHP:
Ver original
  1. $url = "la url indicada anteriomente";
  2. $app_info = file_get_contents($url);
  3. echo '<pre>';
  4. var_dump($app_info); //DEVUELVE FALSE
  5. echo '</pre>';

el query string puede ser mas largo aun, segun la complejidad del problema creo que el error debe venir por ese lado.

el error devuelto es un WARINING
alguna sugerencia?
  #2 (permalink)  
Antiguo 24/04/2016, 03:14
 
Fecha de Ingreso: octubre-2010
Ubicación: España
Mensajes: 1.007
Antigüedad: 13 años, 6 meses
Puntos: 123
Respuesta: url to json

Cita:
el error devuelto es un WARINING
alguna sugerencia?
Y que dice el error?

En teoría y según el RFC 2068 - Hypertext Transfer Protocol -- HTTP/1.1 el protocolo http no establece ningún límite en cuanto al tamaño, pero los servidores y navegadores no siempre pueden atender peticiones excesivamente largas, en cuyo caso devuelven un error 414 ( véase sección 10.4.15 del enlace).

En apache por ejemplo este límite viene dado por la directiva LimitRequestLine.

Algunos navegadores como ie cortan la url al rededor de los 2000 caracteres.
__________________
Unset($vida['malRollo']);

Última edición por xerifandtomas; 24/04/2016 a las 03:44
  #3 (permalink)  
Antiguo 24/04/2016, 07:13
Avatar de 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: url to json

el warining solo devuelve la url y la linea donde se ejecuta:

Código PHP:
Ver original
  1. Warning: file_get_contents(https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/submitJob?token=fFVkoDMXvlfL3BkeAo-MrtS1v3ghp4E9aTpcOPfguiToTlX2h1B3fNBO_7ZeXcU9_BXnTcivllVz-ZAFjtCxL93h76UwVMt8vqhSjD6g2oZVkDuDryMpCqFrGyjAJYN7931dU1gkFqJ1gh8AbWBxDQ..&amp;time_units=Minutes&amp;distance_units=Miles&amp;uturn_policy=NO_UTURNS&amp;populate_directions=true&amp;directions_language=en&amp;default_date=1355212800000&amp;f=json&amp;orders={&quot;features&quot;:[{&quot;geometry&quot;:{&quot;x&quot;:-122.51,&quot;y&quot;:37.7724},&quot;attributes&quot;:{&quot;DeliveryQuantities&quot;:1706,&quot;Name&quot;:&quot;Store_1&quot;,&quot;ServiceTime&quot;:25,&quot;TimeWindowStart1&quot;:1355245200000,&quot;TimeWindowEnd1&quot;:1355274000000,&quot;MaxViolationTime1&quot;:0}},{&quot;geometry&quot;:{&quot;x&quot;:-122.4889,&quot;y&quot;:37.7538},&quot;attributes&quot;:{&quot;DeliveryQuantities&quot;:1533,&quot;Name&quot;:&quot;Store_2&quot;,&quot;ServiceTime&quot;:23,&quot;TimeWi in C:\wamp\www\cloudingsoft\optimocamino.git\tasks\enviar_caminos.php on line 29
  #4 (permalink)  
Antiguo 26/04/2016, 21:31
Avatar de 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: url to json

alguna sugerencia?

Etiquetas: json, url
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:12.