Я пытаюсь получить некоторые данные от Yelp Api и Laravel 5.
Это мой результат. Я понятия не имею, как преобразовать его в правильный формат JSON?
Я использую этот PHP-клиент, чтобы использовать API YELP https://github.com/stevenmaguire/yelp-php
{
region: {
span: {
latitude_delta: 0.029259999999994,
longitude_delta: 0.047640999999999
},
center: {
latitude: 49.1328,
longitude: 9.212475
}
},
total: 113,
businesses: [
{
is_claimed: false,
rating: 3.5,
mobile_url: "http://m.yelp.com/biz/vapiano-heilbronn?utm_campaign=yelp_api&utm_medium=api_v2_search&utm_source=80qGlvEI1gpPmfAxhHEKuQ",
rating_img_url: "https://s3-media1.fl.yelpcdn.com/assets/2/www/img/5ef3eb3cb162/ico/stars/v1/stars_3_half.png",
review_count: 33,
name: "Vapiano",
rating_img_url_small: "https://s3-media1.fl.yelpcdn.com/assets/2/www/img/2e909d5d3536/ico/stars/v1/stars_small_3_half.png",
url: "http://www.yelp.com/biz/vapiano-heilbronn?utm_campaign=yelp_api&utm_medium=api_v2_search&utm_source=80qGlvEI1gpPmfAxhHEKuQ",
categories: [
[
"Italian",
"italian"]
],
phone: "+4971319199950",
snippet_text: "Same same - not different. :) What do you expect from a Vapiano? That it tastes like a Vapiano! Here everything was fine, fresh and good. If you want a...",
image_url: "https://s3-media1.fl.yelpcdn.com/bphoto/Cik80f2i1E_FfhIC7ZX9XQ/ms.jpg",
snippet_image_url: "http://s3-media3.fl.yelpcdn.com/photo/HHcNqfQbtSeBmTEoKAujhA/ms.jpg",
display_phone: "+49 7131 9199950",
rating_img_url_large: "https://s3-media3.fl.yelpcdn.com/assets/2/www/img/bd9b7a815d1b/ico/stars/v1/stars_large_3_half.png",
id: "vapiano-heilbronn",
is_closed: false,
location: {
city: "Heilbronn",
display_address: [
"Kaiserstr. 27",
"74072 Heilbronn",
"Germany"],
geo_accuracy: 8,
postal_code: "74072",
country_code: "DE",
address: [
"Kaiserstr. 27"],
coordinate: {
latitude: 49.141868,
longitude: 9.220792
},
state_code: "BW"}
},
{
is_claimed: false,
rating: 4.5,
mobile_url: "http://m.yelp.com/biz/piccolo-mondo-heilbronn?utm_campaign=yelp_api&utm_medium=api_v2_search&utm_source=80qGlvEI1gpPmfAxhHEKuQ",
rating_img_url: "https://s3-media2.fl.yelpcdn.com/assets/2/www/img/99493c12711e/ico/stars/v1/stars_4_half.png",
review_count: 12,
name: "Piccolo Mondo",
rating_img_url_small: "https://s3-media2.fl.yelpcdn.com/assets/2/www/img/a5221e66bc70/ico/stars/v1/stars_small_4_half.png",
url: "http://www.yelp.com/biz/piccolo-mondo-heilbronn?utm_campaign=yelp_api&utm_medium=api_v2_search&utm_source=80qGlvEI1gpPmfAxhHEKuQ",
categories: [
[
"Italian",
"italian"]
],
phone: "+497131251133",
image_url: "https://s3-media3.fl.yelpcdn.com/bphoto/knoT3BTaCnnx6jsO_KaN5Q/ms.jpg",
location: {
city: "Heilbronn",
display_address: [
"Hauptstr. 9",
"74081 Heilbronn",
"Germany"],
geo_accuracy: 9.5,
postal_code: "74081",
country_code: "DE",
address: [
"Hauptstr. 9"],
coordinate: {
latitude: 49.1195,
longitude: 9.19082
},
state_code: "BW"},
display_phone: "+49 7131 251133",
rating_img_url_large: "https://s3-media4.fl.yelpcdn.com/assets/2/www/img/9f83790ff7f6/ico/stars/v1/stars_large_4_half.png",
id: "piccolo-mondo-heilbronn",
is_closed: false
},
{
is_claimed: false,
rating: 4.5,
mobile_url: "http://m.yelp.com/biz/san-remo-heilbronn?utm_campaign=yelp_api&utm_medium=api_v2_search&utm_source=80qGlvEI1gpPmfAxhHEKuQ",
rating_img_url: "https://s3-media2.fl.yelpcdn.com/assets/2/www/img/99493c12711e/ico/stars/v1/stars_4_half.png",
review_count: 16,
name: "San Remo",
rating_img_url_small: "https://s3-media2.fl.yelpcdn.com/assets/2/www/img/a5221e66bc70/ico/stars/v1/stars_small_4_half.png",
url: "http://www.yelp.com/biz/san-remo-heilbronn?utm_campaign=yelp_api&utm_medium=api_v2_search&utm_source=80qGlvEI1gpPmfAxhHEKuQ",
categories: [
[
"Pizza",
"pizza"],
[
"Italian",
"italian"]
],
phone: "+497131176519",
image_url: "https://s3-media2.fl.yelpcdn.com/bphoto/gI0n6APM2_lRnUWiIiSqxg/ms.jpg",
location: {
city: "Heilbronn",
display_address: [
"Weinsberger Str. 90",
"74076 Heilbronn",
"Germany"],
geo_accuracy: 9.5,
postal_code: "74076",
country_code: "DE",
address: [
"Weinsberger Str. 90"],
coordinate: {
latitude: 49.1461,
longitude: 9.23413
},
state_code: "BW"},
display_phone: "+49 7131 176519",
rating_img_url_large: "https://s3-media4.fl.yelpcdn.com/assets/2/www/img/9f83790ff7f6/ico/stars/v1/stars_large_4_half.png",
id: "san-remo-heilbronn",
is_closed: false
}
]
}
Вы можете сохранить ответ JSON в переменной скажем
$result = <your json value>
и в вашем контроллере:
return response()->json(compact('result'));
ваш ответ будет таким,
{
result: {
<your yelp data>
}
}
Других решений пока нет …