Facebook-API:如何在为页面编写设置时设置 "option" 而不是 "setting/value"
Facebook-API: how to set "option" instead of "setting/value" when writing settings for page
TLDR
我尝试通过 API 更改我的一个 facebook 页面的设置。
语法已更改,但我不知道如何更改。
整个故事
docs 中的示例代码是:
/* PHP SDK v4.0.0 */
/* make the API call */
$request = new FacebookRequest(
$session,
'POST',
'/{page-id}/settings',
array (
'setting' => 'USERS_CAN_POST_VIDEOS',
'value' => false,
)
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */
如果我尝试我得到以下异常:
(#12) 'setting' is deprecated for versions v2.2 and higher
这似乎在变更日志中注明 here
但是我想不出新的语法。当我尝试以下操作时:
$request = new FacebookRequest(
$session,
'POST',
'/{page-id}/settings',
array (
'option' => array(
'USERS_CAN_POST' => true
)
)
);
我收到这个错误:
OAuthException (#100) option requires exactly one key"
并使用此语法:
$request = new FacebookRequest(
$session,
'POST',
'/{page-id}/settings',
array (
'USERS_CAN_POST' => true
)
);
这次出错:
(#100) Requires exactly one and only one of the params: option,setting
那么现在设置选项的正确语法是什么?
谢谢!
我向 facebook 提交了 bug 并在 30 分钟后 (!) 得到了回复。这是所需的格式:
array (
'option' => '{APPEARS_IN_RELATED_PAGES:true}'
)
TLDR 我尝试通过 API 更改我的一个 facebook 页面的设置。 语法已更改,但我不知道如何更改。
整个故事
docs 中的示例代码是:
/* PHP SDK v4.0.0 */
/* make the API call */
$request = new FacebookRequest(
$session,
'POST',
'/{page-id}/settings',
array (
'setting' => 'USERS_CAN_POST_VIDEOS',
'value' => false,
)
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */
如果我尝试我得到以下异常:
(#12) 'setting' is deprecated for versions v2.2 and higher
这似乎在变更日志中注明 here
但是我想不出新的语法。当我尝试以下操作时:
$request = new FacebookRequest(
$session,
'POST',
'/{page-id}/settings',
array (
'option' => array(
'USERS_CAN_POST' => true
)
)
);
我收到这个错误:
OAuthException (#100) option requires exactly one key"
并使用此语法:
$request = new FacebookRequest(
$session,
'POST',
'/{page-id}/settings',
array (
'USERS_CAN_POST' => true
)
);
这次出错:
(#100) Requires exactly one and only one of the params: option,setting
那么现在设置选项的正确语法是什么?
谢谢!
我向 facebook 提交了 bug 并在 30 分钟后 (!) 得到了回复。这是所需的格式:
array (
'option' => '{APPEARS_IN_RELATED_PAGES:true}'
)