Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 15th Sep 2014, 12:55 AM   #1
HyperActive Warrior
 
Join Date: 2014
Location: Noida, India
Posts: 460
Thanks: 203
Thanked 29 Times in 28 Posts
Default
Help me out with this
Share on: 
fb share twitter share gplus share more share

<?php
$fb_id = '36922302396';
$url = 'https://graph.facebook.com/' . urlencode($fb_id);
$result = json_decode( file_get_contents($url) );
printf("%s %s %s", $result->likes, $result->name, $result->link);
?>

This code gives me a result 13480889 Nokia https://www.facebook.com/nokia
where 13480889 is total likes, Nokia is the name of the page and https://www.facebook.com/nokia is the url of the page.

I wish to know if you can help me with:

1. How can i use the html tag < a target = "_blank" > to convert the link into hyperlink so that I can have something like "Click here to visit"!

2. How can monitor performance of 25+ fb_id on an hourly basis with all url underneath each other.

3. Should be displayed in a formatted order with sorted order (descending) on likes.

Syssolution is offline  
Unread 16th Sep 2014, 12:46 AM   #2
HyperActive Warrior
War Room Member
 
Join Date: 2004
Location: , , .
Posts: 179
Thanks: 5
Thanked 44 Times in 33 Posts
Default
Re: Help me out with this
Share on: 
fb share twitter share gplus share more share

<?php
$fb_ids = array('1234','2345','234324',);
function cmp($a, $b) {
if($a->likes==$b->likes) return 0;
return ($a->likes < $b->likes ? 1 : -1);
}
$results = array();
foreach($fb_ids as $fb_id) {
$url = 'https://graph.facebook.com/' . urlencode($fb_id);
$results[] = json_decode( file_get_contents($url) );
}
usort($results, 'cmp');
foreach($results as $result) {
printf('%s %s <a href="%s" rel="nofollow" target="_blank">Click here to visit</a><br />', $result->likes, $result->name, $result->link);
}
phpg is offline  
Unread 16th Sep 2014, 05:13 AM   #3
HyperActive Warrior
 
Join Date: 2014
Location: Noida, India
Posts: 460
Thanks: 203
Thanked 29 Times in 28 Posts
Default
Re: Help me out with this
Share on: 
fb share twitter share gplus share more share

Thanks a lot for the code! Does it resolve all the points?

Syssolution is offline  
Unread 16th Sep 2014, 05:20 AM   #4
HyperActive Warrior
War Room Member
 
Join Date: 2004
Location: , , .
Posts: 179
Thanks: 5
Thanked 44 Times in 33 Posts
Default
Re: Help me out with this
Share on: 
fb share twitter share gplus share more share

Obviously it doesn't run itself hourly.
phpg is offline  
Unread 16th Sep 2014, 05:31 AM   #5
HyperActive Warrior
 
Join Date: 2014
Location: Noida, India
Posts: 460
Thanks: 203
Thanked 29 Times in 28 Posts
Default
Re: Help me out with this
Share on: 
fb share twitter share gplus share more share

Originally Posted by phpg View Post

Obviously it doesn't run itself hourly.
Thanks a ton!

Syssolution is offline  
Closed Thread


Bookmarks

Tags
modification, php


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 05:54 AM.