01.
<?php
02.
03.
error_reporting
(E_ALL);
04.
require_once
(
'lib/facebook.php'
);
05.
06.
07.
$config
=
array
();
08.
$config
[
'app_id'
] =
"2139281xxxxxxxx"
;
09.
$config
[
'app_secret'
] =
"59f34ae8d3a99ce0fc3c38eexxxxxxxx"
;
11.
$facebook
=
new
Facebook(
array
(
12.
'appId'
=>
$config
[
'app_id'
],
13.
'secret'
=>
$config
[
'app_secret'
],
14.
'cookie'
=> true
15.
));
16.
17.
$user_id
=
$facebook
->getUser();
18.
$name_pic
=
""
;
19.
$message
=
'Test random image by Fog'
;
20.
$arr_file
=
array
();
21.
$allowed_types
=
array
(
'jpg'
,
'jpeg'
,
'gif'
,
'png'
);
22.
$dir
=
"image/"
;
23.
24.
25.
$Op_dir
= opendir(
$dir
);
26.
while
((
$file
= readdir(
$Op_dir
)) !== false) {
27.
if
((
$file
!==
"."
) && (
$file
!==
".."
)){
28.
$arr_file
[] =
$file
;
29.
}
30.
}
31.
$index
=
array_rand
(
$arr_file
, 1);
32.
$name_pic
=
$arr_file
[
$index
];
33.
34.
$albums
=
$facebook
->api(
'/me/albums'
);
35.
echo
"<pre>"
;
36.
print_r(
$albums
);
37.
echo
"</pre>"
;
38.
?>