0

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;

?>
  • Could be one of a bunch of things. I see left and right quotations. set debug = 1 to force php errors to the screen. What's the php version? Is php turned on in the template? input or output? or is this part of an addon? What is httpful? Is that the SDK for the API? – Jim Wyse Apr 12 '19 at 12:06
0

Does your php page works outside EE? I had that kind of problem with a phone script returning an error.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.