문제 설명
앱 사용자의 담벼락에 자신으로 게시하려면 액세스 토큰이 필요합니까? (Do you need an access token to post on app user's wall as themself?)
Hi I'm trying to figure out how to post on app user's wall from my application as themself. I'm using the PHP SDK 3.2.2. Here's my codes so far.
$facebook = new Facebook(
array(
'appId' => 1234567890abcdefg,
'secret' => 1234567890abcdefg,
'cookie' => true,
)
);
$facebookId = '1234567890';
$status = array(
'message' => 'Message',
'name' => 'Name',
'description' => 'Description',
'link' => 'http://www.google.com',
'picture' => 'http://www.something.com/placehold.gif',
);
$facebook‑>api('/'.$facebookId.'/feed/', 'post', $status);
This will work fine and it will post a status update on the user's wall (e.g. App User shared a link via app‑dev.) without having me to specify the access token.
I'm reading the How‑To from Facebook and it says that
If your app publishes on behalf of its users and requires an access token with no expiration time for the purpose of publishing, you should use an App Access Token.
So is it required for me to specify an access token? If yes, where to I specify them? Thanks.
참조 솔루션
방법 1:
The PHP SDK has a setAccessToken()
function. You can use that to set the token to your application access token.
You can easily get your app token by combining your application id and secret separated by a pipe (|
) character, like this:
$fbConfig = array(
'appId' => 1234567890abcdefg,
'secret' => 1234567890abcdefg,
'cookie' => true,
)
$facebook = new Facebook($fbConfig);
$facebook‑>setAccessToken($fbConfig['appId'] .'|'. $fbConfig['secret']);
You'll now be able to perform actions on behalf of your application.