API Technical Question

Community Beginner ,
Oct 09, 2017 Oct 09, 2017

Copy link to clipboard

Copied

I use the Fotolia API to showcase Fotolia images on our site.  Everything is working fine except for one page (was working in the past), and it involves listing all works by a particular artist.  I am no longer able to get API results back.  Can you have a quick look at the code below to see if there is anything that jumps out in the code?

<?php

//error_reporting(E_ALL);

  $search_params = array(

                    'creator_id' =>$_GET['ArtistID'],

                    'language_id' => 2,

                    'limit' => 100,

'offset' => $_GET['offset'],

// 'order' => 'price_1',

'filters' => array('content_type:photo'=>1)

                );

//print_r($search_params);

$request =  xmlrpc_encode_request("xmlrpc.getSearchResults",

array('fotolia-key', $search_params));

$context = stream_context_create(array('http' => array(

    'method' => "POST",

    'header' => "Content-Type: text/xml",

    'content' => $request

)));

$file = file_get_contents("http://api.fotolia.com/Xmlrpc/rpc", false, $context);

$response = xmlrpc_decode($file);

if ($response && xmlrpc_is_fault($response)) {

//   trigger_error("xmlrpc: $response[faultString] ($response[faultCode])");

} else {

?>

Many thanks,

Arny

TOPICS
Fotolia

Views

293

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Community Beginner , Oct 09, 2017 Oct 09, 2017
I should also add the code further down the page.  The results are returned in a table, and depending on the number of results, the table is formatted differently.<?php $counter = 0;echo "<table width=\"100%\" height=\"100%\">";echo "<tr>";foreach ($response as $value){if($counter == 0){  $counter = $counter + 1;continue;}echo "<td align=\"center\" valign=\"top\">";echo "<a href=PhotoDetails.php?id=" . $value['id'] . ">" . $value['thumbnail_html_tag']. "</a>"  ;//echo $value['licenses']['name'];...

Likes

Translate

Translate
Community Beginner ,
Oct 09, 2017 Oct 09, 2017

Copy link to clipboard

Copied

LATEST

I should also add the code further down the page.  The results are returned in a table, and depending on the number of results, the table is formatted differently.

<?php

$counter = 0;

echo "<table width=\"100%\" height=\"100%\">";

echo "<tr>";

foreach ($response as $value)

{

if($counter == 0)

{

  $counter = $counter + 1;

continue;

}

echo "<td align=\"center\" valign=\"top\">";

echo "<a href=PhotoDetails.php?id=" . $value['id'] . ">" . $value['thumbnail_html_tag']. "</a>"  ;

//echo $value['licenses']['name'];

//foreach ($value['licenses'] as $license) {

// echo '<li>' .  $license['name'] . " price =  " . $license['price'] . '</li>';

// }

/*echo "<br>";

echo "<b><font face='Arial, Helvetica, sans-serif' color='#0080C0'><font color='#000000' face='Verdana, Arial, Helvetica, sans-serif' size='1'>" . $value['title'] . "</font></font></b>";

echo "<br>";

echo "<font face='Verdana, Arial, Helvetica, sans-serif' size='2'><font size='1'>" . $value['creator_name'] . "</font>";*/

echo "<br><br>";

echo "<span class=\"style25\"><span class=\"style27\"><span class=\"style28\"><a href=PhotoDetails.php?id=" . $value['id'] . "></a></span></span></span>";

echo "</td> ";

if( $counter%4==0)

{

echo "</tr>"; 

echo "<tr>"; 

}

$counter = $counter + 1;

}

echo "</tr>";

echo "<tr><td colspan=4 align='center'><br>";

// include("jPaginate/jPaginate.html");

/* Paging Logic  - Starts */

$totalPages = ceil($response['nb_results']/100);

$currentPage = intval($_GET['offset'])/100+1;

/* Paging Logic  - Ends */

echo "<a style='color: white; text-decoration:none; background-color: #7A0000; border: 1px solid rgb(255, 255, 255); padding-bottom:3px; padding-top:3px; padding-left:7px; padding-right:7px;' href=\"http://mysite/PhotosByArtist.php?ArtistID="  . $_GET['ArtistID'] . "&ArtistName=" . $_GET['ArtistName'] . "&offset=0\">First</a>";

if($currentPage>1)

echo "    <a style='text-decoration:none; color: white; background-color: #7A0000; border: 1px solid rgb(255, 255, 255); padding-bottom:3px; padding-top:3px; padding-left:7px; padding-right:7px;' href=\"http://mysite/PhotosByArtist.php?ArtistID="  . $_GET['ArtistID'] . "&ArtistName=" . $_GET['ArtistName'] . "&offset=" . ($currentPage-2)*100 . "\">Previous</a>";

if($currentPage<>$totalPages)

echo "    <a style='text-decoration:none; color: white; background-color: #7A0000; border: 1px solid rgb(255, 255, 255); padding-bottom:3px; padding-top:3px; padding-left:7px; padding-right:7px;' href=\"http://mysite/PhotosByArtist.php?ArtistID="  . $_GET['ArtistID'] . "&ArtistName=" . $_GET['ArtistName'] . "&offset=" . ($currentPage*100) . "\">Next</a>";

echo "    <a style='text-decoration:none; color: white; background-color: #7A0000; border: 1px solid rgb(255, 255, 255); padding-bottom:3px; padding-top:3px; padding-left:7px; padding-right:7px;' href=\"http://mysite/PhotosByArtist.php?ArtistID="  . $_GET['ArtistID'] . "&ArtistName=" . $_GET['ArtistName'] . "&offset=" . ($totalPages-1)*100 . "\">Last</a>";

      echo "<br><br><b>Total Stock Photos Found:</b> " . $response['nb_results'] . "";

echo "</td></tr>";

echo "</table> ";

}

?>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines