Jump to content

Search the Community

Showing results for tags 'twitterapi'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. So I have this PHP script below that requests data from the Twitter API and then displays it on the page according to the information that I have in my local database because I stored twitter usernames of some twitter users so I can pass them to the API and display the profile images of those twitter users. The script works fine to display my request from the API but it is AWFULLY slow , so I was wondering what could cause the script to be so slow ... Below is my script .. the first part seems to execute fine... /* Create a TwitterOauth object with consumer/user tokens. */ $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']); $url = $connection->get('statuses/user_timeline', array('screen_name' => $row['Twitter'],count=>'1')); $results = json_encode($url); $data = json_decode($results, true); $image = ''; if(is_array($data)){ $image = $data[0]['user']['profile_image_url']; $image_bigger = str_replace('_normal', '_bigger',$image); } echo "<h1 align='middle' id = $id> $name Vs Opposition </h1>"; echo "<img src='".$image_bigger."' width= '100' height ='100' class= 'image' align='middle' />"; ?> //This part of the script below seems to be the culprit of the page taking so long to display info because it loops through all the twitter IDs returned by the query in order to display the images of the authors that I request through the API inside the loop . $data2 variable is very long array of info regarding the twitter user and from that array , I pick the key of the array containing the value that stores the picture of every twitter user inside a loop .. How could I dynamically optimize this so I can get all those images ? <?php $select2 = "SELECT * FROM AUTHORS WHERE ID <> $id"; $result2 = mysql_query($select2); $result_count = mysql_num_rows($result2); $image_array = array(); $unique_id = array(); $counter = 0; if($result_count > 0) { while ($row2 = mysql_fetch_array($result2, MYSQL_ASSOC)) { array_push($unique_id, $row2['ID']); $url2 = $connection->get('statuses/user_timeline', array('screen_name' => $row2['Twitter'],count=>'1')); $results2 = json_encode($url2); $data2 = json_decode($results2, true); // data through is a very long array $image2 = $data2[$counter]['user']['profile_image_url']; $image3 = str_replace('_normal', '_bigger',$image2); array_push($image_array,$image3); } } var_dump($data2); exit; ?> <div id="test"> <iframe id="frame" src="" width="100%" height="100% frameBorder="0" "> </iframe> </div> <div id ="opposition"> <?php $unique_image = array_unique($image_array); $id_array = array_unique($unique_id); $i = 0; foreach($unique_image as $content) { echo "<a id ='".$id_array[$i]."' href ='#'><img src='".$content."' width= '100' height ='100' class='image' /></a>"; $i++; } ?> </div>
×
×
  • 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.