-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFbConnect.php
More file actions
46 lines (33 loc) · 1.15 KB
/
FbConnect.php
File metadata and controls
46 lines (33 loc) · 1.15 KB
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
<?php
require_once("FacebookGraphAPIUtil.inc");
$config = parse_ini_file("config.ini");
$pageId = $config["page_id"];
$appId = $config["app_id"];
$appSecret = $config["app_secret"];
$redirect = urlencode($config["callback"]);
$reqPerms = $config["perms"];
$callback = $_REQUEST["callback"];
$code = $_REQUEST["code"];
$fb = new FacebookGraphAPIUtil($appId, $appSecret, $redirect, $reqPerms);
if(empty($code)) {
header("Location: {$fb->getAuthUrl()}");
}
$accessToken = $fb->getAccessToken($code);
$fbUser = $fb->getFbUserData($accessToken);
$result['user'] = $fbUser;
// post parameter
// http://developers.facebook.com/docs/reference/api/post/
$p = array(
"access_token" => $accessToken,
"message" => "投稿てすとテストTEST",
"picture" => "http://k.yimg.jp/images/top/sp/logo.gif",
"link" => "http://www.yahoo.co.jp/",
"name" => "テストほげほげ",
"description" => "投稿てすてすてすててててててててt"
);
// user wall
$result['user_feed'] = $fb->postFeed($fbUser->id, $p);
// page post
$result['page_feed'] = $fb->postFeed($pageId, $p);
mb_convert_variables('SJIS', 'UTF-8', $result);
var_dump($result);