Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6804257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:26:37+00:00 2026-05-26T19:26:37+00:00

i have php function that parses a xml url and gives me an array.this

  • 0

i have php function that parses a xml url and gives me an array.this functions uses a perticular id and gives all information related to that id which is passed in the form. now i have 20 different ids and i am passing these id’s in this form using foreach loop like below

<?php 
    $relatedSlides = $result['RelatedSlideshows'];
    if(!empty($relatedSlides)){
        $k=1;
        foreach($relatedSlides as $Related){
            RelatedSlides($Related);
            if($k%6==0){
                echo '</tr><tr>';
            }
            $k++;
        }
    }
?>

This is the foreach loop. $relatedSlides is an array of all slide id’s. Now I am writing the function that parses the information about a particular id.

function RelatedSlides($slideId){
    $secret_key = 'my api key';
    $ts=time();
    $hash=sha1($secret_key.$ts);
    $key = 'my secret key';
    $url = 'http://www.slideshare.net/api/2/get_slideshow?api_key='.$key.'&ts='.$ts.'& hash='.$hash.'&slideshow_id='.$slideId.'&detailed=1';
    echo $url;
    $ch=curl_init() or die (curl_error());
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla Firefox');
    $query = curl_exec($ch);
    $errorCode = curl_errno($ch); 
    curl_close($ch);
    $array = (array) simplexml_load_string($query);
    //echo '<pre>';
    //print_r($array);
    //return $array;
    echo "<font size=\"18\">return code is ".$errorCode."</font>";
    echo '<td valign="top"><div id="slide_thumb"><a href="viewslide.php?slideId='.$array['ID'].'&title='.$array['StrippedTitle'].'"><img src=" '.$array['ThumbnailURL'].'" width="100" height="100"/></a></div><div id="slide_thum_des"><strong>Views:</strong>'.$array['NumViews'].'<br /><ahref="'.$array['DownloadUrl'].'">'.$array['Title'].'....</a></div></td>';
}

When I call this function my connection times out every time. The function is absolutely correct. It gives all data about a particular id but when I run it in a foreach loop for many id’s, “connection has been reset” or “connection timed out” displays.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:26:38+00:00Added an answer on May 26, 2026 at 7:26 pm

    You could try a couple of things:

    1. Setup your curl handler outside of the RelateSlides() function. This way you don’t have to keep building and tearing down the $ch resource every iteration.

    2. Check the slideshare.net api and see if there are params you can pass to pull down smaller files.

    3. As Luke wisely mentioned, you could make the page asyncronous, meaning you can render the page with 6 tiles, then have each tile make an ajax call for the slide you want. This way at least the user gets to see something while the tiles load, as opposed to being ‘hung up’ while you pull all the images at once.

    4. I trust slideshare has a pretty robust cdn hosting these images, you may want to see if they have servers closer to your web server.

    Quick question, is the curl option how slideshare.net suggested you go about pulling images? Chances are you could just create an image tag with a link directly to their api:

     echo '<img src="http://www.slideshare.net/api/2/get_slideshow?api_key='.$key.'&ts='.$ts.'& hash='.$hash.'&slideshow_id='.$slideId.'&detailed=1' />';
    

    If you are doing the curl option for extended data, you may want to consider caching the extended data so you don’t have to keep making the extraneous simplexml_load_string call.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a function in PHP that calls a webservice and parses through
I have a function, that gets a large XML file, then parses it, and
I have a PHP script that parses an array using the json_encode() method but
I have a PHP function that takes a variable number of arguments (using func_num_args()
I have a PHP function that requires can take 3 parameteres... I want to
Is it possible to have a PHP function that is both recursive and anonymous?
I have a php function I wrote that will take a text file and
I have written a PHP function to take a video embed code that has
I have a function that I use on index.php page and I would like
I have a function that finds a regex thingy, then replaces with php code.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.