We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Custom PHP

Development and Programming

dagga's avatar
dagga
15 posts
6 years ago
dagga's avatar dagga

We have a need to pull in data from an external source using PHP. I’ve run into this issue before where EE doesn’t like the PHP formatting i’m using, yet it seems to work elsewhere. For example, if i type the same code into phpfiddle it works fine. When i put it into EE i get the error {!– ra:000000007fef5f44000000007fd6e88d –} or something similar. Please see the code below. Any ideas of why this wouldn’t work? I do put the API key in and “URLGOESHERE” is where the actual API URL is.. i just removed for here.Thanks!

<?php

require “util/httpful.phar”; $API_KEY = “”;

$startAt = 1; $maxReturn = 20; $url = “https://URLGOESHERE/sws/v1/offers/cruise?filter=supplier_id=26;searchable_destination_id=2&fields=offer_id,title&start;_at={$startAt}&max;_return={$maxReturn}”;

$response = Httpful\Request::get($url) ->addHeader(‘api_key’, $API_KEY) ->send(); $offers = json_decode($response, true); $total = $response->body->meta->total;

$returnHtml = “<h1>Top Cruises</h1><ul>”; foreach( $offers[“offers”] as $offer ) { $returnHtml .= “<li><a href=”https://URLGOESHERE/index.cfm/cruise/offer/index?offerID={$offer">{$offer['offer_id']} - {$offer['title']}</li>”; }

$returnHtml .= “</ul>”; $returnHtml .= “Showing results {$startAt} - {$maxReturn} of {$total}”;

echo $returnHtml;

?>

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.