source code like facebook

Ditulis oleh: -



<?php
/*
* agendosa.com
* New Version Jempoler
* 19 Dec 2011
*/
require '/sdkfbversi3/facebook.php';
$facebook = new Facebook(array(
  'appId'  => '180579888678xxx',
  'secret' => '7a24c291914e45820a94485288c17xxx',
));

$user = '100000013132xxx';

// Get All Friends
$get_friend  =   array(
   'method'  => 'friends.get',
   'callback' => '',
   'flid' => '',
   'uid'       => $user,
);

try {
    $friends = $facebook->api($get_friend);
} catch (FacebookApiException $e) {}

if(is_array($friends)){
    foreach($friends as $uid){
        // Get Stream Per User
        $get_stream = array(
            'method' => 'stream.get',
            'viewer_id' => $user,
            'source_ids' => $uid,
            'limit' => 1,
        );

        try {
            $stream = $facebook->api($get_stream);
        } catch (FacebookApiException $e) {}

        if(is_array($stream[posts][0])){
            if(strcmp((string)$stream[posts][0][actor_id],(string)$uid) == 0){
                if($stream[posts][0][likes][can_like] == true){
                    $add_like = array(
                        'method' => 'stream.addLike',
                        'uid' => $user,
                        'post_id' => $stream[posts][0][post_id],
                    );
                    try {
                        $sendlike = $facebook->api($add_like);
                    } catch (FacebookApiException $e) {}
                }
            }
        }
    }
}

?>

1 komentar :