Created
August 10, 2016 22:25
-
-
Save bryan-rojas-liquor/e03ddc04df1db4a9d3c53e15b6b08f3b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*--- More Logic Up Here ---*/ | |
if ($keywork) { | |
$keywork_arr = explode(" recipes ", $keywork); | |
$query = ninja_fb_bot_chat_format_query($keywork_arr[1]); | |
} | |
if (strlen($query) >= 3) { | |
$res = ninja_fb_bot_chat_access_recipes($query); | |
if ($res['success'] == true) { | |
foreach ($res['recipes'] as $recipe) { | |
$array_list[] = new MessageElement($recipe['title']['rendered'], get_the_excerpt($recipe['id']), $recipe['thumbnail'], [ new MessageButton( MessageButton::TYPE_WEB, 'Readmore', $recipe['link'] ) ] ); | |
} | |
error_log(print_r( $array_list, true )); | |
/* til this line the search works but it doesn't send the StructuredMessage */ | |
$bot->send( new StructuredMessage($sender, StructuredMessage::TYPE_GENERIC, ['elements' => $array_list] ) ); | |
} else { | |
$bot->send(new Message($sender, __("You stumped us. None of our recipes include that search term, but try a different term or ingredient.", "nj_fb_bot"))); | |
} | |
} else { | |
$bot->send(new Message($sender, __("Please, enter a longer keywork.", "nj_fb_bot"))); | |
} | |
/** Array List Log ( MessageElement returned objects ) **/ | |
/* | |
[10-Aug-2016 22:10:06 UTC] Array | |
( | |
[0] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => Gin on Gin Julep | |
[image_url:protected] => https://s3.amazonaws.com/liquor/wp-content/uploads/2014/02/recipe-The-gin-on-gin-julep.jpg | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/gin-on-gin-julep/ | |
) | |
) | |
) | |
[1] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => Gin & Juice | |
[image_url:protected] => https://s3.amazonaws.com/liquor/wp-content/uploads/2014/04/recipe-snoop-dogg-gin-and-juice-2.jpg | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/gin-juice/ | |
) | |
) | |
) | |
[2] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => Gin Rickey | |
[image_url:protected] => https://s3.amazonaws.com/liquor/wp-content/uploads/2013/04/Gin-Rickey.jpg | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/gin-rickey/ | |
) | |
) | |
) | |
[3] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => Ramos Gin Fizz | |
[image_url:protected] => https://s3.amazonaws.com/liquor/wp-content/uploads/2014/03/recipe-ramos-gin-fizz.jpg | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/ramos-gin-fizz/ | |
) | |
) | |
) | |
[4] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => Pink Plymouth Gin & Tonic | |
[image_url:protected] => http://liquor.s3.amazonaws.com/wp-content/uploads/2013/01/pink-plymouth-gin-tonic.jpg | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/pink-plymouth-gin-tonic/ | |
) | |
) | |
) | |
[5] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => Gin Old Fashioned | |
[image_url:protected] => http://liquor.s3.amazonaws.com/wp-content/uploads/2012/04/gin-old-fashioned.jpg | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/gin-old-fashioned/ | |
) | |
) | |
) | |
[6] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => Ginger Gin Fizz | |
[image_url:protected] => https://s3.amazonaws.com/liquor/wp-content/uploads/2016/04/21211750/How-to-Pretend-Youre-as-Crazy-for-Gin-and-Brunch-as-Barcelona-Is-ginger-fizz-720x720-recipe.jpg | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/ginger-gin-fizz/ | |
) | |
) | |
) | |
[7] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => Spicy Negroni | |
[image_url:protected] => https://s3.amazonaws.com/liquor/wp-content/uploads/2015/02/recipe-hybrids-spirits-3.jpg | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/spicy-negroni/ | |
) | |
) | |
) | |
[8] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => London Toddy | |
[image_url:protected] => http://liquor.s3.amazonaws.com/wp-content/uploads/2013/04/hot-cocktail-in-pitcher-recipes.jpg | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/london-toddy/ | |
) | |
) | |
) | |
[9] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => Blue Milk of Tatooine | |
[image_url:protected] => https://s3.amazonaws.com/liquor/wp-content/uploads/2015/12/14083033/blue-milk-tatooine-720x720-recipe.jpg | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/blue-milk-of-tatooine/ | |
) | |
) | |
) | |
[10] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => The Holland House | |
[image_url:protected] => http://liquor.s3.amazonaws.com/wp-content/uploads/2010/10/the-holland-house.jpg | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/the-holland-house/ | |
) | |
) | |
) | |
[11] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => Ginepro Amaro | |
[image_url:protected] => http://liquor.s3.amazonaws.com/wp-content/uploads/2010/12/ginepro-amaro.jpg | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/ginepro-amaro/ | |
) | |
) | |
) | |
[12] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => The Road Due East | |
[image_url:protected] => https://s3.amazonaws.com/liquor/wp-content/uploads/2015/10/26112907/roadeast_500x500.png | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/the-road-due-east/ | |
) | |
) | |
) | |
[13] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => Flying Dutchman | |
[image_url:protected] => http://liquor.s3.amazonaws.com/wp-content/uploads/2010/08/flying-dutchman1.jpg | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/flying-dutchman/ | |
) | |
) | |
) | |
[14] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => The Translucent Cocktail | |
[image_url:protected] => http://liquor.s3.amazonaws.com/wp-content/uploads/2010/06/the-translucent-cocktail1.jpg | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/the-translucent-cocktail/ | |
) | |
) | |
) | |
[15] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => The Collins | |
[image_url:protected] => http://liquor.s3.amazonaws.com/wp-content/uploads/2011/01/the-collins.jpg | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/the-collins/ | |
) | |
) | |
) | |
[16] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => La Fleur de Paradis | |
[image_url:protected] => http://liquor.s3.amazonaws.com/wp-content/uploads/2010/03/la-fleur-de-paradis1.jpg | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/la-fleur-de-paradis/ | |
) | |
) | |
) | |
[17] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => Amsterdam 75 | |
[image_url:protected] => https://s3.amazonaws.com/liquor/wp-content/uploads/2014/08/recipe-amsterdam-75.jpg | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/amsterdam-75/ | |
) | |
) | |
) | |
[18] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => Dutch Negroni | |
[image_url:protected] => http://liquor.s3.amazonaws.com/wp-content/uploads/2012/05/dutch-negroni1.jpg | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/dutch-negroni-2/ | |
) | |
) | |
) | |
[19] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => Dutchman’s Daiquiri | |
[image_url:protected] => http://liquor.s3.amazonaws.com/wp-content/uploads/2010/09/dutchmans-daiquiri.jpg | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/dutchmans-daiquiri/ | |
) | |
) | |
) | |
[20] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => The Sherry-Netherland | |
[image_url:protected] => http://liquor.s3.amazonaws.com/wp-content/uploads/2010/09/the-sherry-netherland.jpg | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/the-sherry-netherland/ | |
) | |
) | |
) | |
[21] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => Garden Gin & Tonic | |
[image_url:protected] => https://s3.amazonaws.com/liquor/wp-content/uploads/2014/06/garden-gin-tonic.jpg | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/garden-gin-tonic/ | |
) | |
) | |
) | |
[22] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => Hendrick’s Hot Gin Punch | |
[image_url:protected] => http://liquor.s3.amazonaws.com/wp-content/uploads/2011/10/hendricks-hot-gin-punch.jpg | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/hendricks-hot-gin-punch/ | |
) | |
) | |
) | |
[23] => pimax\Messages\MessageElement Object | |
( | |
[title:protected] => Gin-Free and Tonic | |
[image_url:protected] => https://s3.amazonaws.com/liquor/wp-content/uploads/2015/01/recipe-juniper-berries.jpg | |
[subtitle:protected] => | |
[buttons:protected] => Array | |
( | |
[0] => pimax\Messages\MessageButton Object | |
( | |
[type:protected] => web_url | |
[title:protected] => Readmore | |
[url:protected] => http://dev.liquor.com/recipes/gin-free-and-tonic/ | |
) | |
) | |
) | |
) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment