function SavePhoto($urlSource, $picObject, $tagId, $outputDir, $fileFormat, $checkSkip = true) { global $fbcmdPrefs; $photoContents = false; $retry = 0; $fileFormat = str_replace('\\', '/', $fileFormat); if ($picObject) { $fileFormat = str_replace('[aid]', $picObject['aid'], $fileFormat); $fileFormat = str_replace('[pid]', $picObject['pid'], $fileFormat); $fileFormat = str_replace('[oid]', $picObject['owner'], $fileFormat); $fileFormat = str_replace('[oname]', ProfileName($picObject['owner']), $fileFormat); } if ($tagId) { $fileFormat = str_replace('[tid]', $tagId, $fileFormat); $fileFormat = str_replace('[tname]', ProfileName($tagId), $fileFormat); } $outputFile = CleanPath($outputDir) . $fileFormat; VerifyOutputDir($outputFile); if ($fbcmdPrefs['pic_skip_exists'] && $checkSkip) { if (file_exists($outputFile)) { return false; } } do { try { $photoContents = @file_get_contents($urlSource); } catch (Exception $e) { FbcmdWarning("[{$e->getCode()}] {$e->getMessage()}"); } if ($photoContents == false) { if (++$retry > $fbcmdPrefs['pic_retry_count']) { FbcmdWarning("Could not download {$urlSource}"); return false; } else { FbcmdWarning("Retry {$retry} :: {$urlSource}"); sleep($fbcmdPrefs['pic_retry_delay']); } } } while ($photoContents == false); if (file_put_contents($outputFile, $photoContents) == false) { FbcmdWarning("Could not save {$outputFile}"); return false; } return true; }
FbcmdIncludeAddCommand('FNAMES', 'Display all your friend\'s names'); FbcmdIncludeAddCommand('MYNOTES', 'Display all of your notes'); FbcmdIncludeAddCommand('SINGLE', 'Display all of your single friends'); FbcmdIncludeAddCommand('FLSTREAM', 'flist~Get last 150 post from your friend wallpaper'); FbcmdIncludeAddCommand('PCOMMENTS', 'postid~Get last 150 comments from specified postid'); FbcmdIncludeAddCommand('OINFO', '[uids list]~Get finfo for user from uids list'); FbcmdIncludeAddCommand('OMUTUAL', '[uids list]~Get friends of friends mutual friends'); //////////////////////////////////////////////////////////////////////////////// // Step Five: Include (run) FBCMD require dirname(__FILE__) . '/../fbcmd.php'; //////////////////////////////////////////////////////////////////////////////// // Step Six: Add your own commands: if ($fbcmdCommand == 'FNAMES') { GetFlistIds("=all"); foreach ($flistMatchArray as $friendId) { print ProfileName($friendId) . "\n"; } } if ($fbcmdCommand == 'MYNOTES') { $fbReturn = $fbObject->api_client->notes_get($fbUser); foreach ($fbReturn as $note) { print "{$note['title']}\n\n{$note['content']}\n\n\n"; } } if ($fbcmdCommand == 'SINGLE') { $fql = "SELECT name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1={$fbUser}) AND relationship_status='single'"; $fbReturn = $fbObject->api_client->fql_query($fql); foreach ($fbReturn as $singleFriend) { print $singleFriend['name'] . "\n"; } }