001 <?php 002 003 class agendosa extends Exception { } 004 005 require_once '/direktori/tempat/upload/sdk/facebook.php'; 006 007 $appapikey = 'API KEY MU'; 008 009 $appsecret = 'API SECRETMU'; 010 011 $facebook = new Facebook($appapikey, $appsecret); 012 013 function komentar($postid, $komentare, $uids){ 014 015 if(file_exists("$uids")){ 016 017 $cek = fopen("$uids",'r'); 018 019 $str = fgets($cek); 020 021 fclose($cek); 022 023 if(!empty($str) && ($str != $post_id)){ 024 025 if($pot[posts][0][comments][can_post] == 1){ 026 027 $comment = $facebook->api_client->stream_addComment($postid, $komentare, "UID-FB-MU"); 028 029 } 030 031 } 032 033 } 034 035 $log1 = fopen("$uids", 'w'); 036 037 fwrite($log1, $postid); 038 039 fclose($log1); 040 041 } 042 043 $cek_permisi = $facebook->api_client->users_hasAppPermission("read_stream",'UID-FB-MU'); 044 045 if($cek_permisi){ 046 047 $friends = $facebook->api_client->friends_get(null, 'UID-FB-MU'); 048 049 array_push($friends,'UID-FB-MU'); 050 051 foreach ($friends as $uid) 052 053 { 054 055 try{ 056 057 $pot = $facebook->api_client->stream_get('UID-FB-MU',"$uid",'','',1,'','','',''); 058 059 if(is_array($pot)){ 060 061 if($pot[posts][0]){ 062 063 if($pot[posts][0][actor_id]){ 064 065 if($uid == 'UID-FB-MU'){ 066 067 if($pot[posts][0][likes]){ 068 069 if($pot[posts][0][likes][can_like] == 1){ 070 071 $like = $facebook->api_client->stream_addLike($pot[posts][0][post_id], 'UID-FB-MU'); 072 073 } 074 075 } 076 077 }else{ 078 079 if($pot[posts][0][actor_id] == $uid){ 080 081 if(preg_match("/suka/i",$pot[posts][0][message]) or preg_match("/ suka /i",$pot[posts][0][message])){ 082 083 komentar($pot[posts][0][post_id], "like..this..", "$uid"); 084 085 } 086 087 else 088 089 { 090 091 if($pot[posts][0][likes]){ 092 093 if($pot[posts][0][likes][can_like] == 1){ 094 095 $like = $facebook->api_client->stream_addLike($pot[posts][0][post_id], 'UID-FB-MU'); 096 097 } 098 099 } 100 101 } 102 103 } 104 105 } 106 107 } 108 109 } 110 111 } 112 113 }catch(agendosa $e){ 114 115 throw $e; 116 117 } 118 119 sleep(1); 120 121 } 122 123 } 124 125 ?>