forked from dtompkins/fbcmd
-
Notifications
You must be signed in to change notification settings - Fork 1
/
fbcmd.php
4106 lines (3682 loc) · 157 KB
/
fbcmd.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/php
<?php
////////////////////////////////////////////////////////////////////////////////
// __ _ _ //
// / _| | | | //
// | |_| |__ ___ _ __ ___ __| | //
// | _| '_ \ / __| '_ ` _ \ / _` | //
// | | | |_) | (__| | | | | | (_| | //
// |_| |_.__/ \___|_| |_| |_|\__,_| //
// //
// Facebook Command Line Interface Utility //
// //
// [Project Home Page & wiki] http://fbcmd.dtompkins.com //
// [Facebook Page] http://facebook.com/fbcmd //
// [Discussion Group] http://groups.google.com/group/fbcmd //
// [Open Source Repository] http://github.com/dtompkins/fbcmd //
// //
// Copyright (c) 2007,2009 Dave Tompkins //
// //
////////////////////////////////////////////////////////////////////////////////
// //
// This program is free software: you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation, either version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
// //
// see facebook.php, JSON.php & JSON-LICENSE for additional information //
// //
////////////////////////////////////////////////////////////////////////////////
// //
// Having said all that, the author would love you to send him: //
// Suggestions, Modifications and Improvements for re-distribution. //
// //
// http://fbcmd.dtompkins.com/contribute //
// //
////////////////////////////////////////////////////////////////////////////////
// //
// http://fbcmd.dtompkins.com/history/ for a revision history. //
// //
////////////////////////////////////////////////////////////////////////////////
// //
// Disclaimer: This is my first (and currently only) PHP applicaiton, //
// so my apologies if I don't follow PHP best practices. //
// //
////////////////////////////////////////////////////////////////////////////////
$fbcmdVersion = '1.0-beta3-dev13';
////////////////////////////////////////////////////////////////////////////////
// you can include fbcmd.php from another program
// see support/sample-mycmd.php for more information
if (isset($fbcmd_include)) {
ob_end_clean(); // this avoids displaying the #!/usr/bin/php when included
if ($fbcmd_include_supressOutput) {
ob_start();
}
} else {
$fbcmd_argv = $argv;
$fbcmd_argc = $argc;
}
////////////////////////////////////////////////////////////////////////////////
// set the default arguments to be empty
$fbcmdCommand = '';
$fbcmdParams = Array();
$fbcmdPrefs = Array();
////////////////////////////////////////////////////////////////////////////////
// You can set an environment variable FBCMD to specify the location of
// your peronal files: sessionkeys.txt, prefs.php, postdata.txt, maildata.txt
// Defaults: Windows: %USERPROFILE%\fbcmd\ (c:\Users\YOURUSERNAME\fbcmd\)
// Defaults: Mac/Linux/Other: $HOME/.fbcmd/ (~/.fbcmd/)
$fbcmdBaseDir = getenv('FBCMD');
if ($fbcmdBaseDir) {
$fbcmdBaseDir = CleanPath($fbcmdBaseDir);
} else {
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
if (getenv('USERPROFILE')) {
$fbcmdBaseDir = CleanPath(getenv('USERPROFILE')) . 'fbcmd/';
} else {
$fbcmdBaseDir = 'c:/fbcmd/';
}
} else {
$fbcmdBaseDir = CleanPath(getenv('HOME')) . '.fbcmd/';
}
}
////////////////////////////////////////////////////////////////////////////////
// This section sets your preferences
// see http://fbcmd.dtompkins.com/preferences for more information
// STEP ONE: System Defaults
// Do NOT change these System Default preference values here:
// Modify your own prefs.php file instead
AddPreference('albumfile',"{$fbcmdBaseDir}albumdata.txt",'afile');
AddPreference('album_save','1','asave');
AddPreference('apics_filename','[pid].jpg','af');
AddPreference('appkey','d96ea311638cf65f04b33c87eacf371e');
AddPreference('appsecret','88af69b7ab8d437bff783328781be79b');
AddPreference('auth_auto_launch','1');
AddPreference('auto_mkdir','1');
AddPreference('csv_bookend','"');
AddPreference('csv_escaped_bookend','""');
AddPreference('csv_force_bookends','0','csvf');
AddPreference('csv_separator',',');
AddPreference('delpost_comment_fail','1');
AddPreference('eventfile',"{$fbcmdBaseDir}eventdata.txt",'efile');
AddPreference('event_dateformat','D M d H:i','edf');
AddPreference('event_save','1','esave');
AddPreference('events_attend_mask','15','emask');
AddPreference('facebook_debug','0','debug');
AddPreference('feed_template','60736970450');
AddPreference('fevents_attend_mask','1','fmask');
AddPreference('fgroups_show_id','1','gid');
AddPreference('flist_chunksize','10','ch');
AddPreference('folder_blankrow','1','fbr');
AddPreference('folder_dateformat','M d H:i','fdf');
AddPreference('folder_show_date','0','fd');
AddPreference('folder_show_snippet','1','snip');
AddPreference('folder_show_threadid','0','tid');
AddPreference('fpics_filename','[pid].jpg','ff');
AddPreference('go_default_numeric','link');
AddPreference('keyfile',"{$fbcmdBaseDir}sessionkeys.txt",'key');
AddPreference('launch_exec','');
AddPreference('mail_save','1','msave');
AddPreference('mailfile',"{$fbcmdBaseDir}maildata.txt",'mfile');
AddPreference('mkdir_mode',0777);
AddPreference('msg_blankrow','1','mbr');
AddPreference('msg_dateformat','M d H:i','mdf');
AddPreference('msg_show_date','0','md');
AddPreference('noticefile',"{$fbcmdBaseDir}noticedata.txt",'nfile');
AddPreference('notices_blankrow','1','nbr');
AddPreference('notices_dateformat','M d H:i','ndf');
AddPreference('notices_save','1','nsave');
AddPreference('notices_show_date','0','nd');
AddPreference('notices_show_id','0','nid');
AddPreference('online_idle','1','idle');
AddPreference('opics_filename','[pid].jpg','of');
AddPreference('pic_dateformat','M d Y','pdf');
AddPreference('pic_retry_count','10','pr');
AddPreference('pic_retry_delay','2','prd');
AddPreference('pic_show_albumid','0','paid');
AddPreference('pic_show_date','0','pd');
AddPreference('pic_show_links','0','plink');
AddPreference('pic_show_src','0','psrc');
AddPreference('pic_size','1','psize');
AddPreference('pic_skip_exists','1','pskip');
AddPreference('postfile',"{$fbcmdBaseDir}postdata.txt",'pfile');
AddPreference('ppic_size','1','ppsize');
AddPreference('ppics_filename','[tid].jpg','pf');
AddPreference('prefix_filter','#');
AddPreference('prefix_friendlist','_');
AddPreference('prefix_group','~');
AddPreference('prefix_page','+');
AddPreference('prefix_tag','@');
AddPreference('prefix_username','!');
AddPreference('prefs','');
AddPreference('print_blanks','0','bl');
AddPreference('print_clean','1','clean');
AddPreference('print_col_padding','2','pad');
AddPreference('print_csv','0','csv');
AddPreference('print_header','1','hdr');
AddPreference('print_linefeed_subst',' ');
AddPreference('print_wrap','1','wrap');
AddPreference('print_wrap_cut','1','cut');
AddPreference('print_wrap_env_var','COLUMNS');
AddPreference('print_wrap_min_width','20');
AddPreference('print_wrap_width','80','col');
AddPreference('quiet','0','q');
AddPreference('restatus_comment_new','1');
AddPreference('savepref_include_files','0','spf');
AddPreference('show_id','0','id');
AddPreference('status_dateformat','D M d H:i','stdf');
AddPreference('status_show_date','0','std');
AddPreference('status_tag','1','tag');
AddPreference('status_tag_order','friends:username:0,friends:name:0,pages:username:0,pages:name:0,friends:name:1,pages:name:1,groups:name:0,groups:name:1');
AddPreference('status_tag_syntax','/@(\S+)/');
AddPreference('stream_blankrow','1','sbr');
AddPreference('stream_dateformat','D H:i','sdf');
AddPreference('stream_new_from','created_time');
AddPreference('stream_save','1','ssave');
AddPreference('stream_show_appdata','0','sapp');
AddPreference('stream_show_attachments','0','satt');
AddPreference('stream_show_comments','1','scom');
AddPreference('stream_show_date','0','sd');
AddPreference('stream_show_likes','1','slikes');
AddPreference('stream_show_postid','0','sid');
AddPreference('trace','0','t');
AddPreference('update_branch','master');
// Parameter Defaults
AddPreference('default_addalbum_title','');
AddPreference('default_addalbum_description','');
AddPreference('default_addalbum_location','');
AddPreference('default_addalbum_privacy','everyone');
AddPreference('default_addpic_filename','');
AddPreference('default_addpic_albumid',null);
AddPreference('default_addpic_caption','');
AddPreference('default_addpicd_dirname','');
AddPreference('default_addpicd_albumid',null);
AddPreference('default_albums_flist','=ME');
AddPreference('default_allinfo_flist','=ME');
AddPreference('default_apics_albumid','');
AddPreference('default_apics_savedir',false);
AddPreference('default_comment_text','');
AddPreference('default_display_text','FBCMD: The Command Line Interface for Facebook');
AddPreference('default_feed1_text','');
AddPreference('default_feed2_title','');
AddPreference('default_feed2_body','');
AddPreference('default_feed2_imgsrc','');
AddPreference('default_feed2_imglink','');
AddPreference('default_feedlink_link','');
AddPreference('default_feedlink_text','');
AddPreference('default_feednote_title','');
AddPreference('default_feednote_body','');
AddPreference('default_fevents_flist','=ME');
AddPreference('default_fgroups_flist','=ME');
AddPreference('default_finfo_fields','birthday_date');
AddPreference('default_finfo_flist','=ALL');
AddPreference('default_flast_flist','=ME');
AddPreference('default_flast_count','10');
AddPreference('default_fonline_flist','=ALL');
AddPreference('default_fpics_flist','=ME');
AddPreference('default_fpics_savedir',false);
AddPreference('default_friends_flist','=ALL');
AddPreference('default_fstatus_flist','=ALL');
AddPreference('default_fstream_flist','=ALL');
AddPreference('default_fstream_count','10');
AddPreference('default_inbox_count','10');
AddPreference('default_loaddisp_filename','');
AddPreference('default_loadinfo_filename','');
AddPreference('default_loadnote_title','');
AddPreference('default_loadnote_filename','');
AddPreference('default_mutual_flist','=ALL');
AddPreference('default_mywall_count','10');
AddPreference('default_notices_type','');
AddPreference('default_nsend_flist','=ME');
AddPreference('default_nsend_message','');
AddPreference('default_opics_flist','=ME');
AddPreference('default_opics_savedir',false);
AddPreference('default_post_message','');
AddPreference('default_post_name',null);
AddPreference('default_post_link',null);
AddPreference('default_post_caption',null);
AddPreference('default_post_description',null);
AddPreference('default_postimg_message',false);
AddPreference('default_postimg_imgsrc','');
AddPreference('default_postimg_imglink','0');
AddPreference('default_postimg_name',null);
AddPreference('default_postimg_link',null);
AddPreference('default_postimg_caption',null);
AddPreference('default_postimg_description',null);
AddPreference('default_postmp3_message',false);
AddPreference('default_postmp3_mp3src','');
AddPreference('default_postmp3_mp3title','');
AddPreference('default_postmp3_mp3artist','');
AddPreference('default_postmp3_mp3album','');
AddPreference('default_postmp3_name',null);
AddPreference('default_postmp3_link',null);
AddPreference('default_postmp3_caption',null);
AddPreference('default_postmp3_description',null);
AddPreference('default_postvid_message',false);
AddPreference('default_postvid_vidsrc','');
AddPreference('default_postvid_preview','');
AddPreference('default_postvid_name',false);
AddPreference('default_postvid_link',false);
AddPreference('default_postvid_caption',false);
AddPreference('default_postvid_description',false);
AddPreference('default_ppics_flist','=ALL');
AddPreference('default_ppics_savedir',false);
AddPreference('default_recent_flist','=ALL');
AddPreference('default_recent_count','10');
AddPreference('default_savedisp_filename','');
AddPreference('default_saveinfo_filename','');
AddPreference('default_sentmail_count','10');
AddPreference('default_showpref_defaults','0');
AddPreference('default_stream_filter','1');
AddPreference('default_stream_count','10');
AddPreference('default_tagpic_pid','');
AddPreference('default_tagpic_target','=ME');
AddPreference('default_tagpic_x','50');
AddPreference('default_tagpic_y','50');
AddPreference('default_updates_count','10');
AddPreference('default_wallpost_flist','=ME');
AddPreference('default_wallpost_message','');
// STEP TWO: Load preferences from prefs.php in the base directory
if (file_exists("{$fbcmdBaseDir}prefs.php")) {
include("{$fbcmdBaseDir}prefs.php");
}
// STEP THREE: Read switches set from the command line
// This also sets $fbcmdCommand & &fbcmdParams
ParseArguments($fbcmd_argv,$fbcmd_argc);
// STEP FOUR: if a "-prefs=filename.php" was specified
if ($fbcmdPrefs['prefs']) {
if (file_exists($fbcmdPrefs['prefs'])) {
include($fbcmdPrefs['prefs']);
} else {
FbcmdWarning("Could not load Preferences file {$fbcmdPrefs['prefs']}");
}
}
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == 'SAVEPREF') {
ValidateParamCount(0,1);
SetDefaultParam(1,"{$fbcmdBaseDir}prefs.php");
SavePrefs($fbcmdParams[1]);
return;
}
////////////////////////////////////////////////////////////////////////////////
$GLOBALS['facebook_config']['debug'] = $fbcmdPrefs['facebook_debug'];
////////////////////////////////////////////////////////////////////////////////
$fbcmdCommandList = array();
AddCommand('ADDALBUM', 'title [description] [location] [privacy]~Create a new photo album');
AddCommand('ADDPIC', 'filename [album_id|latest] [caption]~Upload (add) a photo to an album');
AddCommand('ADDPICD', 'dirname [album_id|latest]~Upload (add) all *.jpg files in a directory to an album');
AddCommand('ALBUMS', '[flist]~List all photo albums for friend(s)');
AddCommand('ALLINFO', 'flist~List all available profile information for friend(s)');
AddCommand('APICS', 'album_id [savedir]~List [and optionally save] all photos from an album');
AddCommand('AUTH', 'authcode~Sets your facebook authorization code');
AddCommand('COMMENT', 'post_id text~Add a comment to a story that appears in the stream');
AddCommand('DELPOST', 'post_id~Deletes a post from your stream');
AddCommand('DISPLAY', 'fbml~Sets the content of your FBCMD profile box');
AddCommand('EVENTS', '[time]~Display your events');
AddCommand('FEED1', 'title~Add a one-line story to your news feed');
AddCommand('FEED2', 'title body [img_src img_link]~Add a short story to your news feed with optional picture');
AddCommand('FEEDLINK', '[link] text~Share a link in your news feed');
AddCommand('FEEDNOTE', 'title body~Share a note in your news feed');
AddCommand('FEVENTS', 'flist [time]~List events for friend(s)');
AddCommand('FGROUPS', '[flist]~List groups that friend(s) are members of');
AddCommand('FINBOX', '[flist]~Display mail messages from specific friend(s)');
AddCommand('FINFO', 'fields [flist]~List information fields for friend(s) (see UFIELDS)');
AddCommand('FLAST', 'flist [count]~See the last [count] status updates of friend(s)');
AddCommand('FONLINE', '[flist]~List any friends who are currently online');
AddCommand('FPICS', 'flist [savedir]~List [and optionally save] all photos where friend(s) are tagged');
AddCommand('FQL', 'statement [flist]~Perform a custom FQL Query');
AddCommand('FRIENDS', '[flist]~Generate a list of all your friends');
AddCommand('FSTATUS', '[flist]~List current status of friend(s)');
AddCommand('FSTREAM', '[flist] [count|new]~Show stream stories for friend(s)');
AddCommand('FULLPOST', 'post_id~Displays a stream post with all of the comments');
AddCommand('GO', 'destination [id]~Launches a web browser for the given destination');
AddCommand('HELP', '[command|preference]~Display this help message, or launch web browser for [command]');
AddCommand('HOME', '[webpage]~Launch a web browser to visit the FBCMD home page');
AddCommand('INBOX', '[count|unread|new]~Display the latest messages from the inbox');
AddCommand('LIKE', 'post_ids~Like a story that appears in the stream');
AddCommand('LIMITS', '<no parameters>~Display current limits on FBCMD usage');
AddCommand('LOADDISP', 'fbml_filename~Same as DISPLAY but loads the contents from a file');
AddCommand('LOADINFO', 'info_filename~Sets the content of the FBCMD section on your Info Tab');
AddCommand('LOADNOTE', 'title filename~Same as FEEDNOTE but loads the contents from a file');
AddCommand('MSG', 'message_id~Displays a full message thread (e.g.: after an INBOX)');
AddCommand('MUTUAL', 'flist~List friend(s) in common with other friend(s)');
AddCommand('MYWALL', '[count|new]~Show the posts from other users to your wall');
AddCommand('NOTICES', '[unread|markread]~See notifications from facebook, applications & users');
AddCommand('NOTIFY', '<no parameters>~See (simple) notifications such as # of unread messages');
AddCommand('NSEND', 'flist message~Send a notification message to friend(s)');
AddCommand('OPICS', 'flist [savedir]~List [and optionally save] all photos owned by friend(s)');
AddCommand('PINBOX', '[count|unread|new]~Display the inbox (latest updates) from pages you are a fan of');
AddCommand('POST', 'message [name] [link] [caption] [desc]~Post (share) a story in your stream');
AddCommand('POSTIMG', 'message img_src [img_link] [name] [link] [caption] [desc]~Post (share) an image in your stream');
AddCommand('POSTMP3', 'msg mp3_src [title] [artist] [album] [name] [link] [caption] [desc]~Post (share) an .mp3 file in your stream');
AddCommand('POSTVID', 'message vid_src img_src [name] [link] [caption] [desc]~Post (share) a video in your stream');
AddCommand('PPICS', '[flist] [savedir]~List [and optionally save] all profile photos of friend(s)');
AddCommand('RECENT', '[flist] [count]~Shows the [count] most recent friend status updates');
AddCommand('RESET', '<no parameters>~Reset any authorization codes set by AUTH');
AddCommand('RESTATUS', 'message~Replace your status (deletes your status and adds a new status)');
AddCommand('SAVEDISP', 'fbml_filename~Saves the content of your FBCMD profile box to a file');
AddCommand('SAVEINFO', 'info_filename~Saves the content of the FBCMD section on your Info Tab to a file');
AddCommand('SAVEPREF', '[filename]~Save your current preferences / switch settings to a file');
AddCommand('SENTMAIL', '[count|unread|new]~Display the latest messages from the sent mail folder');
AddCommand('SFILTERS', '<no parameters>~Display available stream filters for the STREAM command');
AddCommand('SHOWPREF', '[0|1]~Show your current preferences (and optionally defaults too)');
AddCommand('STATUS', '[message]~Set your status (or display current status if no parameter)');
AddCommand('STREAM', '[filter_rank|filter_key|#filter_name] [count|new]~Show stream stories (with optional filter -- see SFILTERS)');
AddCommand('TAGPIC', 'pic_id target [x y]~Tag a photo');
AddCommand('UFIELDS', '<no parameters>~List current user table fields (for use with FINFO)');
AddCommand('UPDATE', '[branch] [dir] [trace] [ignore_err]~Update FBCMD to the latest version');
AddCommand('USAGE', '(same as HELP)');
AddCommand('VERSION', '[branch]~Check for the latest version of FBCMD available');
AddCommand('WALLPOST', 'flist message~Post a message on the wall of friend(s)');
AddCommand('WHOAMI', '<no parameters>~Display the currently authorized user');
if (isset($fbcmd_include_newCommands)) {
foreach ($fbcmd_include_newCommands as $c) {
AddCommand($c[0],$c[1]);
}
}
////////////////////////////////////////////////////////////////////////////////
if (in_array($fbcmdCommand,array('DFILE','FEED','FEED3','FSTATUSID','FLSTATUS','PICS'))) {
FbcmdFatalError("{$fbcmdCommand} has been deprecated:\n visit http://fbcmd.dtompkins.com/commands/" . strtolower($fbcmdCommand) . " for more information");
}
////////////////////////////////////////////////////////////////////////////////
if (!in_array($fbcmdCommand,$fbcmdCommandList)&&($fbcmdCommand != '')) {
FbcmdFatalError("Unknown Command: [{$fbcmdCommand}] try fbcmd HELP");
}
////////////////////////////////////////////////////////////////////////////////
if (($fbcmdCommand == 'HELP')||($fbcmdCommand == 'USAGE')) {
ValidateParamCount(0,1);
if (ParamCount() == 0) {
ShowUsage();
}
if (in_array(strtoupper($fbcmdParams[1]),$fbcmdCommandList)) {
LaunchBrowser('http://fbcmd.dtompkins.com/commands/' . strtolower($fbcmdParams[1]));
return;
}
if (isset($fbcmdPrefs[$fbcmdParams[1]])) {
LaunchBrowser('http://fbcmd.dtompkins.com/preferences/' . strtolower($fbcmdParams[1]));
return;
}
FbcmdWarning("HELP: did not recognize [{$fbcmdParams[1]}]");
ShowUsage();
}
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == 'UPDATE') {
ValidateParamCount(0,4);
$updatePhp = CleanPath(realpath(dirname($argv[0]))) . 'fbcmd_update.php';
if (!file_exists($updatePhp)) {
$updatePhpAlt = CleanPath(realpath($fbcmdPrefs['install_dir'])) . 'fbcmd_update.php';
if (file_exists($updatePhpAlt)) {
$updatePhp = $updatePhpAlt;
} else {
FbcmdFatalError("Could not locate [{$updatePhp}]");
}
}
$execCmd = "php \"$updatePhp\"";
if (ParamCount() >= 1) {
$execCmd .= " \"{$fbcmdParams[1]}\"";
}
if (ParamCount() >= 2) {
$execCmd .= " \"{$fbcmdParams[2]}\"";
}
if (ParamCount() >= 3) {
$execCmd .= " {$fbcmdParams[3]}";
}
if (ParamCount() >= 4) {
$execCmd .= " {$fbcmdParams[4]}";
}
passthru($execCmd);
return;
}
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == 'HOME') {
ValidateParamCount(0,1);
SetDefaultParam(1,'');
LaunchBrowser('http://fbcmd.dtompkins.com/' . strtolower($fbcmdParams[1]));
}
////////////////////////////////////////////////////////////////////////////////
AddGoDestination('album', '#An album from the ALBUM command');
AddGoDestination('app', 'The fbcmd page on facebook','http://facebook.com/fbcmd');
AddGoDestination('auth', 'Authorize fbcmd for login',"http://www.facebook.com/code_gen.php?v=1.0&api_key={$fbcmdPrefs['appkey']}");
AddGoDestination('auth-ps', 'Authorize fbcmd for post_stream',"http://www.facebook.com/authorize.php?api_key={$fbcmdPrefs['appkey']}&v=1.0&ext_perm=publish_stream");
AddGoDestination('auth-rm', 'Authorize fbcmd for read_mailbox',"http://www.facebook.com/authorize.php?api_key={$fbcmdPrefs['appkey']}&v=1.0&ext_perm=read_mailbox");
AddGoDestination('auth-rs', 'Authorize fbcmd for read_stream',"http://www.facebook.com/authorize.php?api_key={$fbcmdPrefs['appkey']}&v=1.0&ext_perm=read_stream");
AddGoDestination('contribute', 'The fbcmd contact page','http://fbcmd.dtompkins.com/contribute');
AddGoDestination('editapps', 'The facebook edit applications page','http://www.facebook.com/editapps.php');
AddGoDestination('event', '#An event from the EVENT command');
AddGoDestination('faq', 'The fbcmd FAQ','http://fbcmd.dtompkins.com/faq');
AddGoDestination('friend.name', 'The facebook page of your friend...uses status tagging','http://fbcmd.dtompkins.com/faq');
AddGoDestination('github', 'The source repository at github','http://github.com/dtompkins/fbcmd');
AddGoDestination('group', 'The fbcmd discussion group','http://groups.google.com/group/fbcmd');
AddGoDestination('help', 'the fbcmd help page','http://fbcmd.dtompkins.com/help');
AddGoDestination('home', 'The fbcmd home page','http://fbcmd.dtompkins.com');
AddGoDestination('inbox', 'Your facebook inbox','http://www.facebook.com/inbox');
AddGoDestination('install', 'The fbcmd installation page','http://fbcmd.dtompkins.com/installation');
AddGoDestination('link', '#A link from a post from the STREAM command');
AddGoDestination('msg', '#A mail thread from he INBOX command');
AddGoDestination('notice', '#A notice from the NOTICES command');
AddGoDestination('post', '#A post from the STREAM command');
AddGoDestination('stream', 'Your facebook home page','http://www.facebook.com/home.php');
AddGoDestination('update', 'The fbcmd update page','http://fbcmd.dtompkins.com/update');
AddGoDestination('wall', 'Your facebook profile');
AddGoDestination('wiki', 'The fbcmd wiki','http://fbcmd.dtompkins.com');
AddGoDestination('a', '#shortcut for [album]');
AddGoDestination('e', '#shortcut for [event]');
AddGoDestination('m', '#shortcut for [msg]');
AddGoDestination('n', '#shortcut for [notice]');
AddGoDestination('p', '#shortcut for [post]');
AddGoDestination('l', '#shortcut for [link]');
if ($fbcmdCommand == 'GO') {
if (ParamCount() == 0) {
print "\nGO Destinations:\n\n";
foreach ($goDestinations as $key) {
$desc = $goDestinationsHelp[$key];
if (substr($desc,0,1) == "#") {
print str_pad(" go {$key} id",19,' ') . substr($desc,1) . "\n";
} else {
print str_pad(" go {$key}",19,' ') . $desc . "\n";
}
}
print "\n";
return;
} else {
if (isset($goDestinationsUrl[strtolower($fbcmdParams[1])])) {
LaunchBrowser($goDestinationsUrl[strtolower($fbcmdParams[1])]);
return;
}
}
}
////////////////////////////////////////////////////////////////////////////////
require_once('facebook/facebook.php');
require_once('facebook/facebook_desktop.php');
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == 'RESET') {
ValidateParamCount(0);
VerifyOutputDir($fbcmdPrefs['keyfile']);
if (@file_put_contents($fbcmdPrefs['keyfile'],"EMPTY\nEMPTY\n# only the first two lines of this file are read\n# use fbcmd RESET to replace this file\n") == false) {
FbcmdFatalError("Could not generate keyfile {$fbcmdPrefs['keyfile']}");
}
if (!$fbcmdPrefs['quiet']) {
print "keyfile {$fbcmdPrefs['keyfile']} has been RESET\n";
}
}
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == 'AUTH') {
ValidateParamCount(1);
try {
$fbObject = new FacebookDesktop($fbcmdPrefs['appkey'], $fbcmdPrefs['appsecret']);
$session = $fbObject->do_get_session($fbcmdParams[1]);
TraceReturn($session);
} catch (Exception $e) {
FbcmdException($e,'Invalid AUTH code / could not authorize session');
}
$fbcmdUserSessionKey = $session['session_key'];
$fbcmdUserSecretKey = $session['secret'];
VerifyOutputDir($fbcmdPrefs['keyfile']);
if (@file_put_contents ($fbcmdPrefs['keyfile'],"{$fbcmdUserSessionKey}\n{$fbcmdUserSecretKey}\n# only the first two lines of this file are read\n# use fbcmd RESET to replace this file\n") == false) {
FbcmdFatalError("Could not generate keyfile {$fbcmdPrefs['keyfile']}");
}
try {
$fbObject->api_client->session_key = $fbcmdUserSessionKey;
$fbObject->secret = $fbcmdUserSecretKey;
$fbObject->api_client->secret = $fbcmdUserSecretKey;
$fbUser = $fbObject->api_client->users_getLoggedInUser();
$fbReturn = $fbObject->api_client->users_getInfo($fbUser,array('name'));
TraceReturn($fbReturn);
} catch (Exception $e) {
FbcmdException($e,'Invalid AUTH code / could not generate session key');
}
if (!$fbcmdPrefs['quiet']) {
print "\nfbcmd [v$fbcmdVersion] AUTH Code accepted.\nWelcome to FBCMD {$fbReturn[0]['name']}.\n";
}
return;
}
////////////////////////////////////////////////////////////////////////////////
if (!file_exists($fbcmdPrefs['keyfile'])) {
print "\n";
print "Welcome to fbcmd! [version $fbcmdVersion]\n\n";
print "It appears to be the first time you are running the application\n";
print "as fbcmd could not locate your keyfile: [{$fbcmdPrefs['keyfile']}]\n\n";
ShowAuth();
return;
}
////////////////////////////////////////////////////////////////////////////////
$fbcmdKeyFile = file($fbcmdPrefs['keyfile'],FILE_IGNORE_NEW_LINES);
if (count($fbcmdKeyFile) < 2) {
FbcmdFatalError("Invalid keyfile {$fbcmdPrefs['keyfile']}");
}
$fbcmdUserSessionKey = $fbcmdKeyFile[0];
$fbcmdUserSecretKey = $fbcmdKeyFile[1];
if (strncmp($fbcmdUserSessionKey,'EMPTY',5) == 0) {
ShowAuth();
return;
}
////////////////////////////////////////////////////////////////////////////////
// create the Facebook Object
try {
$fbObject = new FacebookDesktop($fbcmdPrefs['appkey'], $fbcmdPrefs['appsecret']);
$fbObject->api_client->session_key = $fbcmdUserSessionKey;
$fbObject->secret = $fbcmdUserSecretKey;
$fbObject->api_client->secret = $fbcmdUserSecretKey;
$fbUser = $fbObject->api_client->users_getLoggedInUser();
} catch (Exception $e) {
FbcmdException($e,'Could not use session key / log in user');
}
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == '') {
ShowUsage();
}
////////////////////////////////////////////////////////////////////////////////
// GLOBAL FQL strings for FLISTS
$fqlFriendId = "SELECT uid2 FROM friend WHERE uid1={$fbUser} AND uid2=uid2";
$fqlFriendBaseInfo = "SELECT uid,first_name,last_name,name,username,birthday_date,online_presence,status FROM user WHERE uid IN (SELECT uid2 FROM #fqlFriendId) OR uid={$fbUser}";
$keyFriendBaseInfo = 'uid';
$fqlFriendListNames = "SELECT flid,name FROM friendlist WHERE owner={$fbUser}";
$keyFriendListNames = 'flid';
$fqlFriendListMembers = "SELECT flid,uid FROM friendlist_member WHERE flid IN (SELECT flid FROM #fqlFriendListNames)";
$fqlPageId = "SELECT page_id FROM page_fan WHERE uid={$fbUser}";
$fqlPageNames = "SELECT page_id,name,username FROM page WHERE page_id IN (SELECT page_id FROM #fqlPageId)";
$keyPageNames = 'page_id';
$fqlGroupNames = "SELECT gid,name FROM group WHERE gid IN (SELECT gid FROM group_member WHERE uid={$fbUser})";
$keyGroupNames = 'gid';
$flistMatchArray = Array();
$flistMatchIdString = '';
////////////////////////////////////////////////////////////////////////////////
PrintStart();
////////////////////////////////////////////////////////////////////////////////
if (isset($fbcmd_include_newCommands)) {
foreach ($fbcmd_include_newCommands as $c) {
if ($fbcmdCommand == $c[0]) {
return;
}
}
}
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == 'ADDALBUM') {
ValidateParamCount(1,4);
SetDefaultParam(1,$fbcmdPrefs['default_addalbum_title']);
SetDefaultParam(2,$fbcmdPrefs['default_addalbum_description']);
SetDefaultParam(3,$fbcmdPrefs['default_addalbum_location']);
SetDefaultParam(4,$fbcmdPrefs['default_addalbum_privacy']);
if (!in_array($fbcmdParams[4],array('friends','friends-of-friends','networks','everyone'))) {
FbcmdFatalError("ADDALBUM 4th parameter must be one of:\n friends,friends-of-friends,networks,everyone");
}
try {
$fbReturn = $fbObject->api_client->photos_createAlbum($fbcmdParams[1],$fbcmdParams[2],$fbcmdParams[3],$fbcmdParams[4]);
TraceReturn($fbReturn);
} catch (Exception $e) {
FbcmdException($e);
}
PrintHeaderQuiet('AID',PrintIfPref('pic_show_links','LINK'));
PrintRowQuiet($fbReturn['aid'],PrintIfPref('pic_show_links',$fbReturn['link']));
}
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == 'ADDPIC') {
ValidateParamCount(1,3);
SetDefaultParam(1,$fbcmdPrefs['default_addpic_filename']);
SetDefaultParam(2,$fbcmdPrefs['default_addpic_albumid']);
SetDefaultParam(3,$fbcmdPrefs['default_addpic_caption']);
if (!file_exists($fbcmdParams[1])) {
FbcmdFatalError("Could not find file {$fbcmdParams[1]}");
}
$fbcmdParams[2] = GetAlbumId($fbcmdParams[2]);
try {
$fbReturn = $fbObject->api_client->photos_upload($fbcmdParams[1], $fbcmdParams[2], $fbcmdParams[3], $fbUser);
TraceReturn($fbReturn);
} catch (Exception $e) {
FbcmdException($e);
}
PrintHeaderQuiet('PID',PrintIfPref('pic_show_links','LINK'),PrintIfPref('pic_show_src','SRC'));
PrintRowQuiet($fbReturn['pid'],PrintIfPref('pic_show_links',$fbReturn['link']),PrintIfPref('pic_show_src',PhotoSrc($fbReturn)));
}
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == 'ADDPICD') {
ValidateParamCount(1,2);
SetDefaultParam(1,$fbcmdPrefs['default_addpicd_dirname']);
SetDefaultParam(2,$fbcmdPrefs['default_addpicd_albumid']);
$fileList = FileMatches($fbcmdParams[1],'jpg');
$fbcmdParams[2] = GetAlbumId($fbcmdParams[2]);
if (count($fileList) > 0) {
PrintHeaderQuiet('PID',PrintIfPref('pic_show_links','LINK'),PrintIfPref('pic_show_src','SRC'));
foreach ($fileList as $fileName) {
try {
$fbReturn = $fbObject->api_client->photos_upload($fileName, $fbcmdParams[2], '', $fbUser);
TraceReturn($fbReturn);
} catch (Exception $e) {
FbcmdException($e);
}
PrintRowQuiet($fbReturn['pid'],PrintIfPref('pic_show_links',$fbReturn['link']),PrintIfPref('pic_show_src',PhotoSrc($fbReturn)));
}
} else {
FbcmdFatalError("Could Not Find files in {$fbcmdParams[1]}");
}
}
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == 'ALBUMS') {
ValidateParamCount(0,1);
SetDefaultParam(1,$fbcmdPrefs['default_albums_flist']);
GetFlistIds($fbcmdParams[1],true);
$fql = "SELECT aid,owner,name,size,created,link FROM album WHERE owner IN ({$flistMatchIdString})";
try {
$fbReturn = $fbObject->api_client->fql_query($fql);
TraceReturn($fbReturn);
} catch(Exception $e) {
FbcmdException($e);
}
if (!empty($fbReturn)) {
PrintHeader(PrintIfPref('album_save','[#]'),PrintIfPref('show_id','OWNER_ID'),'OWNER_NAME',PrintIfPref('pic_show_albumid','AID'),PrintIfPref('pic_show_date','CREATED'),'NAME','SIZE',PrintIfPref('pic_show_links','LINK'));
$albumNum = 0;
foreach ($fbReturn as $a) {
$albumNum++;
PrintRow(PrintIfPref('album_save','[' . $albumNum. ']'),PrintIfPref('show_id',$a['owner']),ProfileName($a['owner']),PrintIfPref('pic_show_albumid',$a['aid']),PrintIfPref('pic_show_date',date($fbcmdPrefs['pic_dateformat'],$a['created'])),$a['name'],$a['size'],PrintIfPref('pic_show_links',$a['link']));
}
SaveAlbumData($fbReturn);
}
}
////////////////////////////////////////////////////////////////////////////////
$allUserInfoFields = "about_me,activities,affiliations,allowed_restrictions,birthday,birthday_date,books,current_location,education_history,email_hashes,family,first_name,has_added_app,hometown_location,hs_info,interests,is_app_user,is_blocked,last_name,locale,meeting_for,meeting_sex,movies,music,name,notes_count,online_presence,pic,pic_big,pic_big_with_logo,pic_small,pic_small_with_logo,pic_square,pic_square_with_logo,pic_with_logo,political,profile_blurb,profile_update_time,profile_url,proxied_email,quotes,relationship_status,religion,sex,significant_other_id,status,timezone,tv,uid,username,verified,wall_count,website,work_history";
if ($fbcmdCommand == 'ALLINFO') {
ValidateParamCount(0,1);
SetDefaultParam(1,$fbcmdPrefs['default_allinfo_flist']);
GetFlistIds($fbcmdParams[1]);
$fql = "SELECT {$allUserInfoFields} from user where uid in ({$flistMatchIdString}) ORDER BY last_name";
try {
$fbReturn = $fbObject->api_client->fql_query($fql);
TraceReturn($fbReturn);
} catch(Exception $e) {
FbcmdException($e);
}
if (!empty($fbReturn)) {
PrintHeader(PrintIfPref('show_id','UID'),'NAME','FIELD','VALUE');
foreach ($fbReturn as $a) {
PrintRecursiveObject(array(PrintIfPref('show_id',$a['uid']),ProfileName($a['uid'])),'',$a);
}
}
}
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == 'APICS') {
ValidateParamCount(1,2);
SetDefaultParam(1,$fbcmdPrefs['default_apics_albumid']);
SetDefaultParam(2,$fbcmdPrefs['default_apics_savedir']);
$fbcmdParams[1] = GetAlbumId($fbcmdParams[1]);
$fql = "SELECT pid,aid,owner,src_small,src_big,src,link,caption,created FROM photo WHERE aid IN ({$fbcmdParams[1]})";
try {
$fbReturn = $fbObject->api_client->fql_query($fql);
TraceReturn($fbReturn);
} catch(Exception $e) {
FbcmdException($e);
}
if (!empty($fbReturn)) {
PrintHeader(PrintIfPref('pic_show_albumid','AID'),'PID',PrintIfPref('pic_show_date','CREATED'),'CAPTION',PrintIfPref('pic_show_links','LINK'),PrintIfPref('pic_show_src','SRC'));
foreach ($fbReturn as $pic) {
PrintRow(PrintIfPref('pic_show_albumid',$pic['aid']),$pic['pid'],PrintIfPref('pic_show_date',date($fbcmdPrefs['pic_dateformat'],$pic['created'])),$pic['caption'],PrintIfPref('pic_show_links',$pic['link']),PrintIfPref('pic_show_src',PhotoSrc($pic)));
if ($fbcmdParams[2]) {
SavePhoto(PhotoSrc($pic),$pic,'0',$fbcmdParams[2],$fbcmdPrefs['apics_filename']);
}
}
}
}
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == 'COMMENT') {
ValidateParamCount(2);
SetDefaultParam(2,$fbcmdPrefs['default_comment_text']);
$curPostId = GetPostId($fbcmdParams[1],true);
if ($curPostId) {
try {
$fbReturn = $fbObject->api_client->stream_addComment($curPostId,$fbcmdParams[2]);
TraceReturn($fbReturn);
} catch (Exception $e) {
FbcmdException($e);
}
PrintHeaderQuiet('POST_ID');
PrintRowQuiet($curPostId);
}
}
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == 'DELPOST') {
ValidateParamCount(1);
$curPostId = GetPostId($fbcmdParams[1],true);
if ($fbcmdPrefs['delpost_comment_fail']) {
$commentCount = GetCommentCount($curPostId);
if ($commentCount > 0) {
FbcmdFatalError("[DELPOST] {$curPostId} has comments: -delpost_comment_fail=1");
}
}
if ($curPostId) {
try {
$fbReturn = $fbObject->api_client->stream_remove($curPostId);
TraceReturn($fbReturn);
} catch (Exception $e) {
FbcmdException($e);
}
if ($fbReturn) {
PrintHeaderQuiet('POST_ID');
PrintRowQuiet($curPostId);
} else {
FbcmdFatalError("[DELPOST] Could Not Delete POST_ID {$curPostId}");
}
}
}
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == 'DISPLAY') {
ValidateParamCount(1);
SetDefaultParam(1,$fbcmdPrefs['default_display_text']);
try {
$fbReturn = $fbObject->api_client->profile_setFBML($fbcmdParams[1],null,$fbcmdParams[1],'',$fbcmdParams[1],$fbcmdParams[1]);
TraceReturn($fbReturn);
} catch (Exception $e) {
FbcmdException($e);
}
}
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == 'EVENTS') {
ValidateParamCount(0,1);
SetDefaultParam(1,time());
$eventAttend = ProcessEventMask($fbcmdPrefs['events_attend_mask']);
$fql = "SELECT eid,name,start_time FROM event WHERE eid IN (SELECT eid FROM event_member WHERE uid={$fbUser} AND rsvp_status IN ({$eventAttend})) AND start_time > {$fbcmdParams[1]} ORDER BY start_time";
try {
$fbReturn = $fbObject->api_client->fql_query($fql);
TraceReturn($fbReturn);
} catch (Exception $e) {
FbcmdException($e);
}
if (!empty($fbReturn)) {
PrintHeader(PrintIfPref('event_save','[#]'),'START_TIME','EVENT');
$eventNum = 0;
foreach ($fbReturn as $event) {
$eventNum++;
PrintRow(PrintIfPref('event_save','[' . $eventNum . ']'),date($fbcmdPrefs['event_dateformat'],$event['start_time']),$event['name']);
}
SaveEventData($fbReturn);
}
}
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == 'FEED1') {
ValidateParamCount(1);
SetDefaultParam(1,$fbcmdPrefs['default_feed1_text']);
try {
$fbReturn = $fbObject->api_client->feed_publishUserAction($fbcmdPrefs['feed_template'],array('title-text' => $fbcmdParams[1], 'body-text' => ''),'','',FacebookRestClient::STORY_SIZE_ONE_LINE);
TraceReturn($fbReturn);
} catch (Exception $e) {
FbcmdException($e);
}
}
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == 'FEED2') {
ValidateParamCount(array(2,4));
SetDefaultParam(1,$fbcmdPrefs['default_feed2_title']);
SetDefaultParam(2,$fbcmdPrefs['default_feed2_body']);
if (ParamCount() == 2) {
try {
$fbReturn = $fbObject->api_client->feed_publishUserAction($fbcmdPrefs['feed_template'],array('title-text' => $fbcmdParams[1], 'body-text' => $fbcmdParams[2]),'','',FacebookRestClient::STORY_SIZE_SHORT);
TraceReturn($fbReturn);
} catch (Exception $e) {
FbcmdException($e);
}
}
if (ParamCount() == 4) {
SetDefaultParam(3,$fbcmdPrefs['default_feed2_imgsrc']);
SetDefaultParam(4,$fbcmdPrefs['default_feed2_imglink']);
try {
$fbReturn = $fbObject->api_client->feed_publishUserAction($fbcmdPrefs['feed_template'],array('title-text' => $fbcmdParams[1], 'body-text' => $fbcmdParams[2], 'images' => array( array('src' => $fbcmdParams[3], 'href' => $fbcmdParams[3]))),'','',FacebookRestClient::STORY_SIZE_SHORT);
TraceReturn($fbReturn);
} catch (Exception $e) {
FbcmdException($e);
}
}
}
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == 'FEEDLINK') {
ValidateParamCount(1,2);
SetDefaultParam(1,$fbcmdPrefs['default_feedlink_link']);
SetDefaultParam(2,$fbcmdPrefs['default_feedlink_text']);
try {
$fbReturn = $fbObject->api_client->links_post($fbcmdParams[1],$fbcmdParams[2]);
TraceReturn($fbReturn);
} catch (Exception $e) {
FbcmdException($e);
}
}
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == 'FEEDNOTE') {
ValidateParamCount(2);
SetDefaultParam(1,$fbcmdPrefs['default_feednote_title']);
SetDefaultParam(2,$fbcmdPrefs['default_feednote_body']);
try {
$fbReturn = $fbObject->api_client->notes_create($fbcmdParams[1],$fbcmdParams[2]);
TraceReturn($fbReturn);
} catch (Exception $e) {
FbcmdException($e);
}
}
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == 'FEVENTS') {
ValidateParamCount(1,2);
SetDefaultParam(1,$fbcmdPrefs['default_fevents_flist']);
SetDefaultParam(2,time());
$eventAttend = ProcessEventMask($fbcmdPrefs['fevents_attend_mask']);
GetFlistIds($fbcmdParams[1],true);
PrintHeader(PrintIfPref('show_id','ID'),'NAME','START_TIME','EVENT');
do {
$curChunkIds = GetNextChunkIds();
if ($curChunkIds) {
$results = MultiFqlById($curChunkIds,"SELECT eid,name,start_time FROM event WHERE eid IN (SELECT eid FROM event_member WHERE uid=[id] AND rsvp_status IN ({$eventAttend})) AND start_time > {$fbcmdParams[2]} ORDER BY start_time");
foreach ($curChunkIds as $id) {
if ($results[$id]) {
foreach ($results[$id] as $event) {
PrintRow(PrintIfPref('show_id',$id),ProfileName($id),date($fbcmdPrefs['event_dateformat'],$event['start_time']),$event['name']);
}
}
}
}
} while ($curChunkIds);
}
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == 'FGROUPS') {
ValidateParamCount(0,1);
SetDefaultParam(1,$fbcmdPrefs['default_fgroups_flist']);
GetFlistIds($fbcmdParams[1],true);
PrintHeader(PrintIfPref('show_id','ID'),'NAME',PrintIfPref('fgroups_show_id','GROUP_ID'),'GROUP');
do {
$curChunkIds = GetNextChunkIds();
if ($curChunkIds) {
$results = MultiFqlById($curChunkIds,"SELECT gid,name FROM group WHERE gid IN (SELECT gid FROM group_member WHERE uid=[id])");
foreach ($curChunkIds as $id) {
if ($results[$id]) {
foreach ($results[$id] as $group) {
PrintRow(PrintIfPref('show_id',$id),ProfileName($id),PrintIfPref('fgroups_show_id',$group['gid']),$group['name']);
}
}