Advertisement
ShawnsSpace

10 comments per post_id

Jul 11th, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.65 KB | None | 0 0
  1. <?php
  2. function GetCH($url){
  3. $ch=null;
  4. if(!$ch){
  5. $ch = curl_init();
  6. }
  7. curl_setopt($ch, CURLOPT_URL, "".$url."");
  8. curl_setopt($ch, CURLOPT_HEADER, 0);
  9. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  10. curl_setopt($ch, CURLOPT_FORBID_REUSE, true);
  11. curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
  12. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
  13. curl_setopt($ch, CURLOPT_TIMEOUT, 20);
  14. curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
  15. curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
  16. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  17.  
  18. $return=curl_exec($ch);
  19.  if(!curl_errno($ch)){
  20. return $return;
  21.  }else{
  22. $fb_fail=curl_error($ch);
  23. return $fb_fail;
  24. }
  25. curl_close($ch);
  26. unset($ch);
  27. }; //json_decode()
  28.  
  29. $query = '{"feed":"SELECT post_id, message,description, actor_id, type,created_time, updated_time,attachment, like_info, comment_info FROM stream WHERE filter_key IN(SELECT filter_key FROM stream_filter WHERE uid = me() AND name in (\'Photos\')) limit 5 offset 0"}';
  30. $build = 'https://graph.facebook.com/fql?q='.urlencode($query).'&access_token=USER_TOKEN';
  31.  
  32. $returned=GetCH($build);
  33. $locs=json_decode($returned, true);
  34.  
  35. echo '<pre>';
  36. print_r($locs);
  37. echo '</pre>';
  38. $commentquery = '{';
  39. foreach($locs[data][0][fql_result_set] as $key => $value){
  40. $commentquery .= '"'.$value[post_id].'_comments":"select post_id, fromid,text from comment where post_id = \''.$value[post_id].'\' limit 10", ';
  41. }
  42. $commentquery .= '}';
  43. $commentbuild = 'https://graph.facebook.com/fql?q='.urlencode($commentquery).'&access_token=USER_TOKEN';
  44.  
  45. $returned=GetCH($commentbuild);
  46. $locsc=json_decode($returned, true);
  47.  
  48. echo '<pre>';
  49. print_r($locsc);
  50. echo '</pre>';
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement