Jump to content

cbrei

New Members
  • Posts

    4
  • Joined

  • Last visited

cbrei's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. ah - wicked good! thanks for the guidance!
  2. wow - this was SUPER helpful! I am nearly there I think - I just can't get the price to display, here is what I have: <?php $client_key = 'c3sbrpbtkbs5gverurfkxpemc'; $sig_key = 'PkkJXNRpO2l0r5u6u0PlCNme1KA8akGejMIjHI5Gkj8'; $base_url = '/locations/horse-inn/menus/?client=' . $client_key; $url = hash_hmac('sha1', $base_url, $sig_key, true); $str = urlencode(base64_encode($url)); $fnl_url = 'http://publishing-api.singleplatform.com' . $base_url . '&signature=' . $str; $ch = curl_init($fnl_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $result = json_decode($response, true); if ($result['data'] && $result['code'] == "200") { foreach ($result['data'] as $data) { if ($data['id'] == "1542722") { foreach ($data['sections'] as $sections) { foreach ($sections['items'] as $items) { echo "<ul id='menu_item'>"; echo "<li id='title'>" . $items['name'] . "</li>"; echo "<ul id='ingredients'><li>" . $items['description'] . "</li></ul>"; foreach ($items['choices'] as $choices) { foreach ($choices['prices'] as $prices) { echo "<li id='price'>" . $prices['min'] . "</li>"; } } echo "</ul>"; } } } } } ?> thoughts?
  3. Correct, it is JSON - and that's part of my issue (I think) - I have a line of code in there: $result = json_decode($response, true); but I'm not sure if I'm using it properly, or if the JSON is structured properly to begin with thanks
  4. I'm attempting to set up menus (and other info) from the SinglePlatform service: https://www.singleplatform.com/ to a WordPress site They have some resources: https://dl.dropboxusercontent.com/u/34479868/Onboarding/SinglePlatform_Publisher_Documentation_V3.pdf https://dl.dropboxusercontent.com/u/34479868/Onboarding/SP_Authentication_V3.php I'm running into trouble with structuring the data retuned from the API into a PHP array, where I can then use to populate the site with individual menu items, etc. I have this php code: <?php $client_key = 'c3sbrpbtkbs5gverurfkxpemc'; $sig_key = 'PkkJXNRpO2l0r5u6u0PlCNme1KA8akGejMIjHI5Gkj8'; $base_url = '/locations/horse-inn/menus/?client=' . $client_key; $url = hash_hmac('sha1',$base_url, $sig_key, true); $str = urlencode(base64_encode($url)); $fnl_url = 'http://publishing-api.singleplatform.com'.$base_url.'&signature='.$str; $ch = curl_init($fnl_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec( $ch ); $result = json_decode($response, true); parse_str($response, $valueArray); echo "<pre>", print_r($valueArray, true), "</pre>"; ?> where $client_key and $sig_key are unique variables for my SinglePlatform account the return looks like this: Array ( [{"code":200,"data":_{"id":1542722,"location_id":"horse-inn","name":"Main Menu","description":"","menu_type":"Menu","footnote":"","order_num":0,"currency":"USD","created":"2015-05-29T03:25:24","updated":"2015-06-02T09:34:01","attribution_image":"http://a.singleplatform.com/DirectBusinessIntegration/horse-inn/provided_by_2.png","attribution_image_link":"http://www.singleplatform.com/partner-lp?ref] => DirectBusinessIntegration [sp_channel] => viral [sp_source] => publisher [sp_campaign] => DirectBusinessIntegration","sections":[{"order_num":0,"items":[{"name":"Manhattan #1","choices":[],"photos":[],"order_num":0,"attributes":{},"additions":[],"id":61836457,"description":"Spirit, Angostura [Sam's_French_bread"},{"name":"Beet_] => [goat_cheese_Salad","choices":] => Array ( [{"prices":{"max":"","min":10},"order_num":0,"calories":{"max":"","min":""},"name":"","unit":""}] => ) [extra_virgin_olive_oil"},{"name":"Confit_pork_lettuce_wraps","choices":] => Array ( [{"prices":{"max":"","min":8},"order_num":0,"calories":{"max":"","min":""},"name":"3 for","unit":""},{"prices":{"max":"","min":15},"order_num":1,"calories":{"max":"","min":""},"name":"6 for","unit":""}] => ) [cucumber__Choice_of_house_made_dressing:_Buttermilk_ranch_or_honey_lemon_vinaigrette"},{"name":"Local_strawberry_] => [spinach","choices":] => Array ( [{"prices":{"max":"","min":8},"order_num":0,"calories":{"max":"","min":""},"name":"","unit":""}] => ) [64°_Egg","choices":] => Array ( [{"prices":{"max":"","min":12},"order_num":0,"calories":{"max":"","min":""},"name":"","unit":""}] => ) [Aged_provolone_cheese,_garlic_heavy_cream,_house_hot_sauce"},{"name":"Gyro","choices":] => Array ( [{"prices":{"max":"","min":11},"order_num":0,"calories":{"max":"","min":""},"name":"","unit":""},{"prices":{"max":"","min":14},"order_num":1,"calories":{"max":"","min":""},"name":"With Fries","unit":""}] => ) [tenderloin,_lindendale_Farms_Goats_milk_yogurt_tzatziki,_grilled_tomatoes_] => [onion,_Brogue_Hydroponics_spring_mix"},{"name":"Fried_Green_tomato_BLT","choices":] => Array ( [{"prices":{"max":"","min":11},"order_num":0,"calories":{"max":"","min":""},"name":"","unit":"11"},{"prices":{"max":"","min":14},"order_num":1,"calories":{"max":"","min":""},"name":"With Fries","unit":""}] => ) [10%_dry_aged_beef,_lettuce,_tomato_Red_onion_white_American_cheese,_special_sauce,_Alfred_] => [Sam's_bun"},{"name":"Littleneck_clams","choices":] => Array ( [{"prices":{"max":"","min":15},"order_num":0,"calories":{"max":"","min":""},"name":"","unit":""}] => ) [toast","choices":] => Array ( [{"prices":{"max":"","min":17},"order_num":0,"calories":{"max":"","min":""},"name":"","unit":""}] => ) [Sam's_French_bread,_red_wine_demi-glace"},{"name":"Seasonal_vegetable_plate","choices":] => Array ( [{"prices":{"max":"","min":12},"order_num":0,"calories":{"max":"","min":""},"name":"","unit":""}] => ) [herbs"}],"id":9172490,"description":"","name":"Main"},{"order_num":1,"items":] => Array ( [{"name":"Brown Buttered Cauliflower","choices":[{"prices":{"max":"","min":5},"order_num":0,"calories":{"max":"","min":""},"name":"","unit":""}] => DirectBusinessIntegration ) [Boker's_bitters,_Luxardo_maraschino_liquor,_Carpano_Antica,_orange"},{"name":"Old_Fashioned_#2","choices":] => Array ( [0] => ) [orange,_house_made_grenadine,_egg_white,_orange_bitters"},{"name":"Mint_Julep","choices":] => Array ( [0] => ) ) I have never done an API integration into PHP and am somewhat knowledgable of PHP, but obviously not enough to figure out how to manipulate the API data the menu looks like this on the SinglePlatform site: http://w.singlepage.com/horse-inn/menu many thanks in advance for assistance in resolving this issue
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.