PHP ile Google places api ile işletme bilgilerinizi ve yorumlarınızı kendi sitenizde yayınlayın !

Herkese selam, Google My Business yani Google Benim İşletmem, sık kullanılan bir servis. İşletmeler Google Benim İşletmem kullandıklarında sitelerine ve işletmelerine daha çok ziyaretçi alıyorlar. İnsanlar ziyaret ettikleri işletmeleri Google'da yorumluyor ve işletmelerin detay bilgilerine göz atabiliyor. Google Benim İşletmem kullanan bir işletmeniz olduğunu, ya da müşterinizin bu servisi kullandığını düşünün. Kendi websitesinde ise güzel yorumları öne çıkarmak isteyebilir, ya da işletme bilgilerini kendi internet sitesinde yayınlamak. Google bunun için bizlere Google Places Api hizmetini sunuyor ve bunun kullanımı çok basit.


İşte Google Places Api kullanarak PHP ile sitenizde işletmenize gelen son yorumların ya da diğer detay bilgilerini paylaşmanın kısayolu. 😊


Google Places API platformu hakkında daha fazla detaylı bilgi almak isterseniz bu bağlantıdan daha detaylı bilgilere ulaşabilirsiniz. https://developers.google.com/places/web-service/intro


Öncelikle bu servisi kullanmanız için Google tarafından verilmiş bir API KEY'e ihtiyacınız var. Bu adresteki adımları izleyerek kolayca API KEY alabilirsiniz.

API KEY almak için adres: https://developers.google.com/places/web-service/get-api-key


Bağlantıda nasıl alınacağı anlatılıyor fakat özetleyecek olursam, adres içerisinde bulunan bağlantıdan Google Cloud Platform'a gidip menüden API'ler e tıklayıp Places Apiyi seçip gerekli işlemleri yaptıktan sonra API KEY'inizi alabilirsiniz. (Eğer öğrenci hesabınız varsa Google size belli miktarda hizmeti ücretsiz veriyor 😊)


API KEY'i edindiğinizi varsayarak yazıma devam ediyorum.


İşletme bilgilerinizi çekebilmeniz için 2 tane parametreye ihtiyacınız var.

  1. APIKEY
  2. Place ID


Place ID, sizin işletmenize ait benzersiz bir kimlik numarası. Google Benim İşletmem'de kayıtlı olan firmanızın Place ID'sini bilmiyorsanız, yine Google'ın bize sağlamış olduğu servisten faydalanabilirsiniz. https://developers.google.com/maps/documentation/javascript/examples/places-placeid-finder bu adrese giderek arama alanına işletme adınzı yazarak Place ID'nize ulaşabilirsiniz.



Place ID'nizi de aldıktan sonra işletme bilgilerimizi çekeceğimiz adresi(endpoint) kullanabiliriz.

İstek atacağımız adres : https://maps.googleapis.com/maps/api/place/details/json

Bu adrese yukarıda belirttiğim iki parametreyi ekleyip GET isteği atacağız.

Örnek istek adresi : https://maps.googleapis.com/maps/api/place/details/json?key=API_KEY&placeid=ISLETME_PLACE_IDNIZ


PHP ile CURL kullanarak, paket kullanarak ya da file_get_contents() fonksiyonu ile birlikte bu isteği atıp işletme bilgilerinizi JSON çıktı olarak alabilirsiniz. Ben CURL ile kullandığım yöntemi göstereceğim.


<?php

/* İsteği attığımız adres */
$url = "https://maps.googleapis.com/maps/api/place/details/json?key=API_KEY&placeid=ChIJgTL8ama2yhQR0JwWAPJ-9Gg";

/* Curl isteğimizi başlatıyoruz */
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($ch);

/* İstekten gelen veriyi json_decode kullanarak parçalıyoruz ve bir değişkene atıyoruz. */
$res        = json_decode($result,true);

/* Ben örnek olarak google yorumlarını bana gelen değer içerisinden alıp $reviews adında bir değişkene atıyorum, ve bunu göstereceğim yerde döngüye alarak istediğim verileri listeliyorum. */

$reviews    = $res['result']['reviews'];

print_r($reviews);


?>


Örnek olarak Google Istanbul adresine istek attım ve bu sonuçları aldım.


/* GOOGLE BENİM İŞLETMEM YORUMLAR */

Array
(
    [0] => Array
        (
            [author_name] => Bidur Gurung
            [author_url] => https://www.google.com/maps/contrib/112090200828487313832/reviews
            [language] => en
            [profile_photo_url] => https://lh6.ggpht.com/-S2LVFe9u9Uo/AAAAAAAAAAI/AAAAAAAAAAA/vKf7rAnIJDU/s128-c0x00000000-cc-rp-mo/photo.jpg
            [rating] => 5
            [relative_time_description] => 2 months ago
            [text] => Taha was a great host very clear communication! He explained all my questions or queries and assisted me with the translation. I highly recommend this clinic as they are very safe, secure and clean. Hotel staff was also very helpful and friendly.
            [time] => 1581672357
        )

    [1] => Array
        (
            [author_name] => Murat Meah
            [author_url] => https://www.google.com/maps/contrib/105650820867403085703/reviews
            [language] => en
            [profile_photo_url] => https://lh5.ggpht.com/-DiewUn07pBM/AAAAAAAAAAI/AAAAAAAAAAA/Mf8afcRxUSo/s128-c0x00000000-cc-rp-mo-ba5/photo.jpg
            [rating] => 5
            [relative_time_description] => a year ago
            [text] => Made a quick visit past while I was in the area. Very nice and cosy office in the business district.
Super friendly building staff and as always, amazing Googlers in this building too
            [time] => 1537792091
        )

    [2] => Array
        (
            [author_name] => Sinan Karaoguz
            [author_url] => https://www.google.com/maps/contrib/106021357443534735825/reviews
            [language] => en
            [profile_photo_url] => https://lh4.ggpht.com/-q0orTQ20p6k/AAAAAAAAAAI/AAAAAAAAAAA/arW75n23Dsw/s128-c0x00000000-cc-rp-mo-ba6/photo.jpg
            [rating] => 4
            [relative_time_description] => 2 months ago
            [text] => I have been using google maps may be since 2008 and 8th level local guide. I have hundreds of saved places as favourite, the places I want to go etc. I have noticed that in google maps we can not see our saved places during navigation to a point!
            [time] => 1580667670
        )

    [3] => Array
        (
            [author_name] => ماريا نشوى قيوم
            [author_url] => https://www.google.com/maps/contrib/117530388643851030389/reviews
            [language] => en
            [profile_photo_url] => https://lh5.ggpht.com/-OCFrAPcogqE/AAAAAAAAAAI/AAAAAAAAAAA/Umdw1-jL2WQ/s128-c0x00000000-cc-rp-mo/photo.jpg
            [rating] => 5
            [relative_time_description] => 8 months ago
            [text] => We came here desperately hungry and looking for some delicious food. We were certainly surprised and so happy to see such a welcoming atmosphere. Our waiter was Javed and he was absolutely amazing. 

We ordered the food and he made sure he explained everything for us and helped get the food to us quickly! 

The service is fantastic and the staff are all accommodating and warm welcoming. Definitely recommend this place. Thank You Javed
            [time] => 1566736110
        )

    [4] => Array
        (
            [author_name] => Daniel Klein
            [author_url] => https://www.google.com/maps/contrib/115067299869739486954/reviews
            [language] => en
            [profile_photo_url] => https://lh5.ggpht.com/-LZVJFXno3cM/AAAAAAAAAAI/AAAAAAAAAAA/0jlRFstNs9k/s128-c0x00000000-cc-rp-mo-ba6/photo.jpg
            [rating] => 5
            [relative_time_description] => 6 months ago
            [text] => All Google offices are great. The Istanbul office is no exception to this rule.
            [time] => 1571586888
        )

)


Bu adreste ise, reviews(yorumlar) kısmını almadan, doğrudan attığım isteğin bize gelen sonucunu gösteriyorum. Yani $res değişkenini ekrana yazdırıyorum.


/* GOOGLE API TARAFINDAN GELEN, İŞLETMENİZE AİT DETAY BİLGİLER */	

Array
	(
	[html_attributions] => Array
	(
	)
	

	[result] => Array
	(
	[address_components] => Array
	(
	[0] => Array
	(
	[long_name] => 209
	[short_name] => 209
	[types] => Array
	(
	[0] => street_number
	)
	

	)
	

	[1] => Array
	(
	[long_name] => Tekfen Tower
	[short_name] => Tekfen Tower
	[types] => Array
	(
	[0] => route
	)
	

	)
	

	[2] => Array
	(
	[long_name] => Esentepe
	[short_name] => Esentepe
	[types] => Array
	(
	[0] => administrative_area_level_4
	[1] => political
	)
	

	)
	

	[3] => Array
	(
	[long_name] => 4.Levent
	[short_name] => 4.Levent
	[types] => Array
	(
	[0] => administrative_area_level_3
	[1] => political
	)
	

	)
	

	[4] => Array
	(
	[long_name] => Şişli
	[short_name] => Şişli
	[types] => Array
	(
	[0] => administrative_area_level_2
	[1] => political
	)
	

	)
	

	[5] => Array
	(
	[long_name] => İstanbul
	[short_name] => İstanbul
	[types] => Array
	(
	[0] => administrative_area_level_1
	[1] => political
	)
	

	)
	

	[6] => Array
	(
	[long_name] => Turkey
	[short_name] => TR
	[types] => Array
	(
	[0] => country
	[1] => political
	)
	

	)
	

	[7] => Array
	(
	[long_name] => 34343
	[short_name] => 34343
	[types] => Array
	(
	[0] => postal_code
	)
	

	)
	

	)
	

	[adr_address] => Esentepe Mahallesi Eski Büyükdere Caddesi, <span class="street-address">Esentepe, Tekfen Tower No:209</span>, <span class="postal-code">34343</span> <span class="locality">4.Levent/Şişli</span>/<span class="region">İstanbul</span>, <span class="country-name">Turkey</span>
	[business_status] => OPERATIONAL
	[formatted_address] => Esentepe Mahallesi Eski Büyükdere Caddesi, Esentepe, Tekfen Tower No:209, 34343 4.Levent/Şişli/İstanbul, Turkey
	[formatted_phone_number] => (0212) 339 14 00
	[geometry] => Array
	(
	[location] => Array
	(
	[lat] => 41.082091
	[lng] => 29.009465
	)
	

	[viewport] => Array
	(
	[northeast] => Array
	(
	[lat] => 41.083353680291
	[lng] => 29.011054880291
	)
	

	[southwest] => Array
	(
	[lat] => 41.080655719709
	[lng] => 29.008356919709
	)
	

	)
	

	)
	

	[icon] => https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png
	[id] => 27b3097deae6849310688878353eab05a5dab5d8
	[international_phone_number] => +90 212 339 14 00
	[name] => Google Istanbul
	[opening_hours] => Array
	(
	[open_now] =>
	[periods] => Array
	(
	[0] => Array
	(
	[close] => Array
	(
	[day] => 1
	[time] => 1730
	)
	

	[open] => Array
	(
	[day] => 1
	[time] => 0930
	)
	

	)
	

	[1] => Array
	(
	[close] => Array
	(
	[day] => 2
	[time] => 1730
	)
	

	[open] => Array
	(
	[day] => 2
	[time] => 0930
	)
	

	)
	

	[2] => Array
	(
	[close] => Array
	(
	[day] => 3
	[time] => 1730
	)
	

	[open] => Array
	(
	[day] => 3
	[time] => 0930
	)
	

	)
	

	[3] => Array
	(
	[close] => Array
	(
	[day] => 4
	[time] => 1730
	)
	

	[open] => Array
	(
	[day] => 4
	[time] => 0930
	)
	

	)
	

	[4] => Array
	(
	[close] => Array
	(
	[day] => 5
	[time] => 1730
	)
	

	[open] => Array
	(
	[day] => 5
	[time] => 0930
	)
	

	)
	

	)
	

	[weekday_text] => Array
	(
	[0] => Monday: 9:30 AM – 5:30 PM
	[1] => Tuesday: 9:30 AM – 5:30 PM
	[2] => Wednesday: 9:30 AM – 5:30 PM
	[3] => Thursday: 9:30 AM – 5:30 PM
	[4] => Friday: 9:30 AM – 5:30 PM
	[5] => Saturday: Closed
	[6] => Sunday: Closed
	)
	

	)
	

	[photos] => Array
	(
	[0] => Array
	(
	[height] => 554
	[html_attributions] => Array
	(
	[0] => <a href="https://maps.google.com/maps/contrib/114473967930497058419">Hamit Atici</a>
	)
	

	[photo_reference] => CmRaAAAAwHGCC1f-_MjtpEeOhLXiQ6x_MYg_7ZHinhFLRRijQyi7Hc95dtOZggbM9hs9FJjCRG-NxMu3ZN3zBSIrco5VjIaQsMIV-uL0_ot7J0bQl6ZY9DwjT7yj7KywgTzwvF1REhAlZxfrprgUKrJNYuUkUKOdGhR0na1BW2ljj-CyJpLHZ_R4eHu7Hw
	[width] => 750
	)
	

	[1] => Array
	(
	[height] => 3024
	[html_attributions] => Array
	(
	[0] => <a href="https://maps.google.com/maps/contrib/106517207377528405793">Moritz Adler</a>
	)
	

	[photo_reference] => CmRaAAAA3vIP2Rm8GLEJY5Z7ArXNzxeF7Gjz_Qu9XcK2RkXJuZ8_Djwu7AlH9uHnN4CP_lvQ0ZWM9ShUnpIFQqo01qR_PuosScTgET_BwHEQhs6UjQCmI2Ws8rxEo_Vzxa8lO_yHEhDtbwyrZJQgd5qLi8z7NPEzGhRyqeWQNItjkOSHGPDBOtvU4GlvRA
	[width] => 4032
	)
	

	[2] => Array
	(
	[height] => 3024
	[html_attributions] => Array
	(
	[0] => <a href="https://maps.google.com/maps/contrib/101811402654322935956">Orest Bolohan</a>
	)
	

	[photo_reference] => CmRaAAAAhWM78Mx5JfTXPyu1HIfiJ2vzRGtzBLLBcScR34rMBlhEWNi_JylSmj5Q3fSeejT6NYT2mns4BUSxl9xnTVFwT_2C39Hwv7MLIyuy1c0I_V5MUreTSKnYG_SamRBMMM2cEhBPNPEeASVDGZdKHiBRDZg6GhQR4GyCNoKI3TcxCKePI_Kb2Aiv-g
	[width] => 4032
	)
	

	[3] => Array
	(
	[height] => 2448
	[html_attributions] => Array
	(
	[0] => <a href="https://maps.google.com/maps/contrib/100147755521648680890">Melih Bayram Dede</a>
	)
	

	[photo_reference] => CmRaAAAA7a71YtQzOfRhQvVg16ASf7SVsokwffJ8XZkXALrJ9u5YSjdeW0QVF1IjugC5i2glu-xhavw8JRG_1hpI8YKhU1dBLdnnu6h8HjTtGIcgyVbmHgrxzqxec7fNEyPDLJeNEhAp1xFrsPkZBq2zkVZHbfoJGhRoZB27Rht-1_D7jT1tesfQM5ROQw
	[width] => 3264
	)
	

	[4] => Array
	(
	[height] => 4032
	[html_attributions] => Array
	(
	[0] => <a href="https://maps.google.com/maps/contrib/103307487174993638628">Ömer Özkan Şakar</a>
	)
	

	[photo_reference] => CmRaAAAANIu2bMHVKrOSl13ZjWZ30sZbarP_uni4yYP1gP7oQFoeqRmiWPAWfQcyIseSLEYffnZW3qepT1yWDncVoOSzlkig7891HIX9klMhCmGWkkD92PEb424Biy5Cn53Ru4DqEhBH_7KPq9ZaS-p2Ha8eRP4YGhTax9VqTy3lf1Hp4sWddd_h6_jV6w
	[width] => 3024
	)
	

	[5] => Array
	(
	[height] => 2448
	[html_attributions] => Array
	(
	[0] => <a href="https://maps.google.com/maps/contrib/100147755521648680890">Melih Bayram Dede</a>
	)
	

	[photo_reference] => CmRaAAAAu4l6U5W37lRNKXpeC9uvdoIvsJUOlwJBznpivMaKwGtNn8p_Kwe4u3yeyOGizfX-rmL4GgJtYU2sXY9M-mJLYs_SWisXiWPI33Efa9cDON20bzIlEJP2SCosNSuBQjlLEhAbI1lMJ-XG-wwwUjBRS206GhQVl5B1fGnMor7Edc94DIjwpQ8jvA
	[width] => 3264
	)
	

	[6] => Array
	(
	[height] => 2448
	[html_attributions] => Array
	(
	[0] => <a href="https://maps.google.com/maps/contrib/100147755521648680890">Melih Bayram Dede</a>
	)
	

	[photo_reference] => CmRaAAAAmGTSdVM1Wus-wapSOWKyEnoeZqzThvXeUX2mChxQjEUOUgiZxHyvX_xO2KHvVdhWdpZdQiFtOKhkSYPaxTtVHB1t4nD-mkKk6DQreoOsAJBP-NpSnPFm3j5NHH3xz3jJEhDFDR5bPBhXQxDKKIR3LTuTGhS1O6Cd9k3zOVlJgSmUkjlijlNI1g
	[width] => 3264
	)
	

	[7] => Array
	(
	[height] => 1287
	[html_attributions] => Array
	(
	[0] => <a href="https://maps.google.com/maps/contrib/118445948371232118987">ümit tomar</a>
	)
	

	[photo_reference] => CmRaAAAADmf-RKEQTbTevHdaq51Okz_j1tSGydScAkkD46eyi_E_O-492o7KsUhyZXIirkXAyiejhzDBmTC-gLNjPc3bNZoCfhInRxx6DgDw9Afd7DeT5FpXYK9SHvHEAAgGuJEOEhB4yaHz-l7EBd9_4Sx4k6HIGhTvOY_yYy5720vMvOe8NKpC129LCg
	[width] => 1200
	)
	

	[8] => Array
	(
	[height] => 2448
	[html_attributions] => Array
	(
	[0] => <a href="https://maps.google.com/maps/contrib/100147755521648680890">Melih Bayram Dede</a>
	)
	

	[photo_reference] => CmRaAAAAwBifXK0L1CiWfRpKSD5PkPJoeYOS7IAOUG0PjDqfEcbpMYFWh8Sus6GPfL9mkJdYqo0kdRWV_eb2LA5QMExlWKAXPQxmn_Inru51OtxPKJhEVfxe7G5fzKNWHHnKihwbEhCkgLYKPBFE9DSMUIACV4lEGhSys8Ix0a5V6gBGNPTbJ3jFMCTdFA
	[width] => 3264
	)
	

	[9] => Array
	(
	[height] => 2448
	[html_attributions] => Array
	(
	[0] => <a href="https://maps.google.com/maps/contrib/100147755521648680890">Melih Bayram Dede</a>
	)
	

	[photo_reference] => CmRaAAAA8Qn8K9TlWcTP_TywqC0K17DD31ndCrf1BncwhXlHY8zR8oy7p8LcDho-7etb0N4PJkTmnHgd2w0JU-zhKhsWuD0eBjipjN9QNWtol0xQtZfOIsC-1ex4g3XXwrN-RoKuEhBOWNDEzD2HbWG9_8JTfWEnGhRRfm0Ngj5GHgJgUrVtEBolbPh9wA
	[width] => 3264
	)
	

	)
	

	[place_id] => ChIJgTL8ama2yhQR0JwWAPJ-9Gg
	[plus_code] => Array
	(
	[compound_code] => 32J5+RQ European Side, İstanbul, Turkey
	[global_code] => 8GHF32J5+RQ
	)
	

	[rating] => 3.7
	[reference] => ChIJgTL8ama2yhQR0JwWAPJ-9Gg
	[reviews] => Array
	(
	[0] => Array
	(
	[author_name] => Bidur Gurung
	[author_url] => https://www.google.com/maps/contrib/112090200828487313832/reviews
	[language] => en
	[profile_photo_url] => https://lh6.ggpht.com/-S2LVFe9u9Uo/AAAAAAAAAAI/AAAAAAAAAAA/vKf7rAnIJDU/s128-c0x00000000-cc-rp-mo/photo.jpg
	[rating] => 5
	[relative_time_description] => 2 months ago
	[text] => Taha was a great host very clear communication! He explained all my questions or queries and assisted me with the translation. I highly recommend this clinic as they are very safe, secure and clean. Hotel staff was also very helpful and friendly.
	[time] => 1581672357
	)
	

	[1] => Array
	(
	[author_name] => Murat Meah
	[author_url] => https://www.google.com/maps/contrib/105650820867403085703/reviews
	[language] => en
	[profile_photo_url] => https://lh5.ggpht.com/-DiewUn07pBM/AAAAAAAAAAI/AAAAAAAAAAA/Mf8afcRxUSo/s128-c0x00000000-cc-rp-mo-ba5/photo.jpg
	[rating] => 5
	[relative_time_description] => a year ago
	[text] => Made a quick visit past while I was in the area. Very nice and cosy office in the business district.
	Super friendly building staff and as always, amazing Googlers in this building too
	[time] => 1537792091
	)
	

	[2] => Array
	(
	[author_name] => Sinan Karaoguz
	[author_url] => https://www.google.com/maps/contrib/106021357443534735825/reviews
	[language] => en
	[profile_photo_url] => https://lh4.ggpht.com/-q0orTQ20p6k/AAAAAAAAAAI/AAAAAAAAAAA/arW75n23Dsw/s128-c0x00000000-cc-rp-mo-ba6/photo.jpg
	[rating] => 4
	[relative_time_description] => 2 months ago
	[text] => I have been using google maps may be since 2008 and 8th level local guide. I have hundreds of saved places as favourite, the places I want to go etc. I have noticed that in google maps we can not see our saved places during navigation to a point!
	[time] => 1580667670
	)
	

	[3] => Array
	(
	[author_name] => ماريا نشوى قيوم
	[author_url] => https://www.google.com/maps/contrib/117530388643851030389/reviews
	[language] => en
	[profile_photo_url] => https://lh5.ggpht.com/-OCFrAPcogqE/AAAAAAAAAAI/AAAAAAAAAAA/Umdw1-jL2WQ/s128-c0x00000000-cc-rp-mo/photo.jpg
	[rating] => 5
	[relative_time_description] => 8 months ago
	[text] => We came here desperately hungry and looking for some delicious food. We were certainly surprised and so happy to see such a welcoming atmosphere. Our waiter was Javed and he was absolutely amazing.
	

	We ordered the food and he made sure he explained everything for us and helped get the food to us quickly!
	

	The service is fantastic and the staff are all accommodating and warm welcoming. Definitely recommend this place. Thank You Javed
	[time] => 1566736110
	)
	

	[4] => Array
	(
	[author_name] => Daniel Klein
	[author_url] => https://www.google.com/maps/contrib/115067299869739486954/reviews
	[language] => en
	[profile_photo_url] => https://lh5.ggpht.com/-LZVJFXno3cM/AAAAAAAAAAI/AAAAAAAAAAA/0jlRFstNs9k/s128-c0x00000000-cc-rp-mo-ba6/photo.jpg
	[rating] => 5
	[relative_time_description] => 6 months ago
	[text] => All Google offices are great. The Istanbul office is no exception to this rule.
	[time] => 1571586888
	)
	

	)
	

	[scope] => GOOGLE
	[types] => Array
	(
	[0] => point_of_interest
	[1] => establishment
	)
	

	[url] => https://maps.google.com/?cid=7562809252110572752
	[user_ratings_total] => 123
	[utc_offset] => 180
	[vicinity] => Esentepe Mahallesi Eski Büyükdere Caddesi, Tekfen Tower No:209, 4.Levent
	[website] => https://www.google.com/about/locations/?region=europe&office=istanbul
	)
	

	[status] => OK
	)
	


Bu şekilde Google Places API kullanarak sitenizin detay bilgilerini ve kullanıcı yorumlarını çekebilirsiniz.


İyi çalışmalar 😇

Fatih Kobacık

https://fatihkobacik.com.tr/...

"PHP ile Google places api ile işletme bilgilerinizi ve yorumlarınızı kendi sitenizde yayınlayın !" için hiç yorum yapılmadı.

Henüz yorum yapılmamış.

Yorum yap * E-posta adresiniz yayınlanmayacak.