dataLayer waarde converteren naar een PHP var

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Daniel van Seggelen

Daniel van Seggelen

07/12/2020 15:39:01
Quote Anchor link
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
$ret2 = '["agent_id": 25824, "agent_name": "JAP Indonesia", "attributes": { "agent_ratings_enabled": 0, "approved": 1, "attribute_set_id": 1, "categories": JSON.parse("[5,13]"), "indoor_features": ["Sistem Alarm","Internet broadband","Pendingin ruangan (AC)","Televisi","Telepon"], "is_agent": 1, "listing_type": "Classifieds", "other_features": [], "outdoor_features": ["Garasi","Pengamanan Parkir","Keamanan 24 jam","Pagar penuh"], "price_formatted": "Rp 9.500.000 ", "price_not_shown": false, "seller_is_trusted": 1, "show_listing_address": 1, "show_mobile": 1, "is_whatsapp": 1, "is_viber": 0, "is_facebook": 0, "show_officephone": 0, "top_position": 1, "urlkey_details": "sewa-raung-kantor-di-south-quarter-tower-a-tb-simatupang-fully-furnish.html" ,"building_size":8 ,"furnished":"" ,"furnished_id":0 ,"land_size":8 ,"rooms_total":1 ,"agency_name": "JAP Indonesia" ,"alternate_sku": "77887393" ,"listing_address": "Jl.RA\u0020Kartini\u0020Kav.\u00208\u0020,\u0020Cilandak\u0020Barat,\u0020Jakarta\u0020Selatan,\u0020RT.10\/RW.4,\u0020West\u0020Cilandak,\u0020Jakarta,\u0020South\u0020Jakarta\u0020City,\u0020Jakarta\u002012430" ,"attribute_set_name": "Komersial" ,"currency_code": "IDR" ,"listing_start": "2020-11-11 12:08:15" ,"name": "Sewa\u0020raung\u0020kantor\u0020di\u0020South\u0020Quarter\u0020Tower\u0020A\u0020TB\u0020Simatupang\u0020\u002D\u0020Fully\u0020Furnish" ,"price": 9500000 ,"product_owner": 25824 ,"product_owner_name": "JAP Indonesia" ,"product_owner_url_key": "asia-property" ,"root_category": 5 ,"sku": "CO5FAB71BF804C9ID" ,"status": "active" ,"status_supplier_config": "active" ,"subcategory": "Kantor" ,"subcategory_id": 13 ,"offer_type_id": 1 ,"location_latitude": "-6.2937997733984" ,"location_longitude": "106.78449177088" ,"listing_region": "Jakarta" ,"offer_type": "Rent" ,"listing_area": "TB Simatupang" ,"listing_city": "Jakarta Selatan" ,"image_url": "https://static-id.lamudi.com/static/media/bm9uZS9ub25l/2x2x5x880x396/0d36c1d2043af7.jpg" , }, "country": "id", "description": { "characters":643, "text": "Sewa Kantor lengkap dengan furniture di South Quarter Tower A TB Simatupang Jakarta Selatan : Harga Sudah termasuk : - Furniture Lengkap - Domisili gedung - Listrik 24 jam - air - Service Charge Gedung - Office Boy (Kebersihan) - Keamanan 24 Jam - Reception dan - fasilitas lainnya. Hubungi marketing untuk info lebih lanjut, marketing Online 24 jam. Dapatkan ruang kantor lainnya di area Kuningan, Sudirman, Thamrin, TB Simatupang, Kebun Jeruk, Gatot Subroto - MT Haryono dan lainnya di Sewakantorjakarta.asia", "words":87 }, "device_agent": navigator.userAgent, "device_type": "desktop", "images": 6, "language": "in", "location": { "area": "TB Simatupang", "city": "Jakarta Selatan", "region": "Jakarta" }, "login_state": false, "number_of_product_attributes": 50, "number_of_product_features": 9, "sku": "CO5FAB71BF804C9ID", "title": "Sewa raung kantor di South Quarter Tower A TB Simatupang - Fully Furnish", "page_type": "product"}';
$rta2 = json_decode(trim($ret2), true);


Deze code krijg ik een php simple dom terug.

Zo staat hij er

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
dataLayer = [
        {
            "agent_id": 25824,
            "agent_name": "JAP Indonesia",
            "attributes": {
                "agent_ratings_enabled": 0,
                "approved": 1,
                                "attribute_set_id": 1,
                                "categories": JSON.parse("[5,13]"),
                "indoor_features": ["Sistem Alarm","Internet broadband","Pendingin ruangan (AC)","Televisi","Telepon"],
                "is_agent": 1,
                "listing_type": "Classifieds",
                "other_features": [],
                "outdoor_features": ["Garasi","Pengamanan Parkir","Keamanan 24 jam","Pagar penuh"],
                "price_formatted": "Rp 9.500.000 ",
                "price_not_shown": false,
                "seller_is_trusted": 1,
                "show_listing_address": 1,
                "show_mobile": 1,
                "is_whatsapp": 1,
                "is_viber": 0,
                "is_facebook": 0,
                "show_officephone": 0,
                "top_position": 1,
                "urlkey_details": "sewa-raung-kantor-di-south-quarter-tower-a-tb-simatupang-fully-furnish.html"
                                
                
                ,"building_size":8
                
                
                ,"furnished":""
                ,"furnished_id":0
                ,"land_size":8
                ,"rooms_total":1
                
                ,"agency_name": "JAP Indonesia"
                ,"alternate_sku": "77887393"
                ,"listing_address": "Jl.RA\u0020Kartini\u0020Kav.\u00208\u0020,\u0020Cilandak\u0020Barat,\u0020Jakarta\u0020Selatan,\u0020RT.10\/RW.4,\u0020West\u0020Cilandak,\u0020Jakarta,\u0020South\u0020Jakarta\u0020City,\u0020Jakarta\u002012430"
                ,"attribute_set_name": "Komersial"
                ,"currency_code": "IDR"
                ,"listing_start": "2020-11-11 12:08:15"
                ,"name": "Sewa\u0020raung\u0020kantor\u0020di\u0020South\u0020Quarter\u0020Tower\u0020A\u0020TB\u0020Simatupang\u0020\u002D\u0020Fully\u0020Furnish"
                ,"price": 9500000
                ,"product_owner": 25824
                ,"product_owner_name": "JAP Indonesia"
                ,"product_owner_url_key": "asia-property"
                ,"root_category": 5
                ,"sku": "CO5FAB71BF804C9ID"
                ,"status": "active"
                ,"status_supplier_config": "active"
                ,"subcategory": "Kantor"
                ,"subcategory_id": 13
                ,"offer_type_id": 1
                ,"location_latitude": "-6.2937997733984"
                ,"location_longitude": "106.78449177088"
                ,"listing_region": "Jakarta"
                ,"offer_type": "Rent"
                ,"listing_area": "TB Simatupang"
                ,"listing_city": "Jakarta Selatan"
                
                
                
                
                ,"image_url": "https://static-id.lamudi.com/static/media/bm9uZS9ub25l/2x2x5x880x396/0d36c1d2043af7.jpg"
                ,
            },
            "country": "id",
            "description": {
                "characters":643,
                "text": "Sewa Kantor lengkap dengan furniture di South Quarter Tower A TB Simatupang Jakarta Selatan :  Harga Sudah termasuk :  - Furniture Lengkap - Domisili gedung - Listrik 24 jam - air - Service Charge Gedung - Office Boy (Kebersihan) - Keamanan 24 Jam - Reception dan - fasilitas lainnya.  Hubungi marketing untuk info lebih lanjut, marketing Online 24 jam. Dapatkan ruang kantor lainnya di area Kuningan, Sudirman, Thamrin, TB Simatupang, Kebun Jeruk, Gatot Subroto - MT Haryono dan lainnya di Sewakantorjakarta.asia",
                "words":87
            },
            "device_agent": navigator.userAgent,
                        "device_type": "desktop",
                        "images": 6,
            "language": "in",
            "location": {
                "area": "TB Simatupang",
                "city": "Jakarta Selatan",
                "region": "Jakarta"
            },
            "login_state": false,
                        "number_of_product_attributes": 50,
                                                "number_of_product_features": 9,
            "sku": "CO5FAB71BF804C9ID",
            "title": "Sewa raung kantor di South Quarter Tower A TB Simatupang - Fully Furnish",
            "page_type": "product"
        }
    ];


Als ik deze code valideer worden er fouten aangetroffen, maar hij laad wel via dataLayer.
Ik wil dit dus in een php array plaatsen.
Waat iemand wat hier fout aan is?
Gewijzigd op 07/12/2020 15:41:56 door Daniel van Seggelen
 
PHP hulp

PHP hulp

25/09/2021 10:55:05
 
Ad Fundum

Ad Fundum

09/12/2020 09:47:15
Quote Anchor link
Je kunt snel zien wat er fout aan is als je de JSON door een validator haalt.
Probeer eens https://jsonformatter.curiousconcept.com
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.