<?php
define ( SITE_ROOT_URL
, "http://w...content-available-to-author-only...e.com/" ) ; $array = array ( 'hits' => array ( 0 => array ( 'ID' => '69' , 'Title' => 'This is an example' , 'URL' => 'example/1' , 'Detail' => 'Some description here...' , 'image' => 'image1.png' , 'objectID' => '75877631' ) ) ) ;
foreach ( $array [ 'hits' ] as $key => $value ) {
'title' => $value [ 'Title' ] ,
'image_url' => $value [ 'image' ] ,
'subtitle' => substr ( $value [ 'Detail' ] , 0 , 120 ) , 'type' => 'web_url' ,
'url' => SITE_ROOT_URL. $value [ 'URL' ] . '?utm_source=chatbot' ,
'title' => "Leia mais"
)
)
) ;
}
'type' => 'template' ,
'template_type' => 'generic' ,
'elements' => $messages
)
)
)
) ;
PD9waHAKZGVmaW5lKFNJVEVfUk9PVF9VUkwsICJodHRwOi8vdy4uLmNvbnRlbnQtYXZhaWxhYmxlLXRvLWF1dGhvci1vbmx5Li4uZS5jb20vIik7CiRhcnJheSA9IGFycmF5KCdoaXRzJyA9PiBhcnJheSAoIDAgPT4gYXJyYXkgKCAnSUQnID0+ICc2OScsICdUaXRsZScgPT4gJ1RoaXMgaXMgYW4gZXhhbXBsZScsICdVUkwnID0+ICdleGFtcGxlLzEnLCAnRGV0YWlsJyA9PiAnU29tZSBkZXNjcmlwdGlvbiBoZXJlLi4uJywgJ2ltYWdlJyA9PiAnaW1hZ2UxLnBuZycsICdvYmplY3RJRCcgPT4gJzc1ODc3NjMxJykgKSk7CgokbWVzc2FnZXMgPSBhcnJheSgpOwpmb3JlYWNoICgkYXJyYXlbJ2hpdHMnXSBhcyAka2V5ID0+ICR2YWx1ZSkgewogICAgJG1lc3NhZ2VzW10gPSBhcnJheSgKICAgICAgICAndGl0bGUnID0+ICR2YWx1ZVsnVGl0bGUnXSwKICAgICAgICAnaW1hZ2VfdXJsJyA9PiAkdmFsdWVbJ2ltYWdlJ10sCiAgICAgICAgJ3N1YnRpdGxlJyA9PiBzdWJzdHIoJHZhbHVlWydEZXRhaWwnXSwgMCwgMTIwKSwKICAgICAgICAnYnV0dG9ucycgPT4gYXJyYXkoCiAgICAgICAgICAgIGFycmF5KAogICAgICAgICAgICAgICAgJ3R5cGUnID0+ICd3ZWJfdXJsJywgCiAgICAgICAgICAgICAgICAndXJsJyA9PiBTSVRFX1JPT1RfVVJMLiR2YWx1ZVsnVVJMJ10uJz91dG1fc291cmNlPWNoYXRib3QnLCAKICAgICAgICAgICAgICAgICd0aXRsZScgPT4gIkxlaWEgbWFpcyIKICAgICAgICAgICAgKQogICAgICAgICkKICAgICk7Cn0KJHJlc3VsdCA9IGFycmF5KAogICAgJ21lc3NhZ2VzJyA9PiBhcnJheSgKICAgICAgICAnYXR0YWNobWVudCcgPT4gYXJyYXkoCiAgICAgICAgICAgICd0eXBlJyA9PiAndGVtcGxhdGUnLAogICAgICAgICAgICAncGF5bG9hZCcgPT4gYXJyYXkoCiAgICAgICAgICAgICAgICAndGVtcGxhdGVfdHlwZScgPT4gJ2dlbmVyaWMnLAogICAgICAgICAgICAgICAgJ2VsZW1lbnRzJyA9PiAkbWVzc2FnZXMKICAgICAgICAgICAgKQogICAgICAgICkKICAgICkKKTsKZWNobyBqc29uX2VuY29kZSgkcmVzdWx0LCBKU09OX1BSRVRUWV9QUklOVCk7
stdout
{
"messages": {
"attachment": {
"type": "template",
"payload": {
"template_type": "generic",
"elements": [
{
"title": "This is an example",
"image_url": "image1.png",
"subtitle": "Some description here...",
"buttons": [
{
"type": "web_url",
"url": "http:\/\/www.example.com\/example\/1?utm_source=chatbot",
"title": "Leia mais"
}
]
}
]
}
}
}
}
stderr
PHP Notice: Use of undefined constant SITE_ROOT_URL - assumed 'SITE_ROOT_URL' in /home/EZBI6X/prog.php on line 2