Sorting by facebook likes
duhol Offline
Junior Member
**
Posts: 34
Joined: Mar 2011
Post: #5
RE: Sorting by facebook likes
I make a task

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
{
	global $mybb, $db, $lang;
	$threads = array();
	// Update thread likes
	$query = $db->query("
		SELECT tid
		FROM ".TABLE_PREFIX."threads
		GROUP BY tid
	");
	while($thread = $db->fetch_array($query))
	{
			$source_url[] = "http://www.sentens.pl/showthread.php?tid=".$thread['tid'];
			$url = "http://api.facebook.com/restserver.php?method=links.getStats&urls=".implode( ',', $source_url );
			$xml = file_get_contents($url);
			$xml = simplexml_load_string($xml);

			foreach( $xml -> link_stat as $l)
			{
				$total = $l -> total_count;
				$db->update_query("threads", array('likes' => "{$total}"), "tid='{$thread['tid']}'", 1, true);
			}
	}
}
?>


but it take much time for 1000 threads. Is there a way to optimize it?


(10-14-2011 08:06 AM)ZiNgA BuRgA Wrote:  Why are you making a new table?
What is the $tid variable doing?

I think you really should think through what you're writing.
Actually, before you even do that, take the time and think through the design properly and how you're going to architect this, and why.

I dont know how to coding. I learn when I want to make something. Dont be so rough for me Erf
(This post was last modified: 10-14-2011 09:33 AM by duhol.)
10-14-2011 09:27 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
Sorting by facebook likes - duhol - 10-13-2011, 06:03 AM
RE: Sorting by facebook likes - duhol - 10-13-2011, 01:06 PM
RE: Sorting by facebook likes - duhol - 10-14-2011 09:27 AM
RE: Sorting by facebook likes - duhol - 10-15-2011, 07:34 PM
RE: Sorting by facebook likes - duhol - 10-16-2011, 05:05 AM
RE: Sorting by facebook likes - duhol - 10-16-2011, 06:01 AM
RE: Sorting by facebook likes - duhol - 10-16-2011, 08:58 PM

 Standard Tools
Forum Jump: