无法使用Facebook PHP SDK
问题描述:
我想从我的应用程序发送批次通知,几个应用程序用户发送批量应用通知乳宁下面的代码,我得到的响应错误后:无法使用Facebook PHP SDK
"{"error":{"message":"(#100) Must specify a non-empty template `param","type":"OAuthException","code":100}}"`
虽然模板参数是设置...
欣赏什么我做错了任何帮助..
这里是我的代码使用方法:
$batched_request = array();
foreach ($users as $idx => $user) {
$request = array(
'method' => 'POST',
'relative_url' => '/' . $user['id'].'/notifications',
'access_token' => $app_access_token,
'template' => $template,
'href' => $href
);
$batched_request[] = json_encode($request);
}
$params = array('batch' => '[' . implode(',',$batched_request) . ']');
try {
$response = $facebook->api('/','POST',$params);
} catch(FacebookApiException $e) {
error_log($e);
}
答
如果您通过批处理API进行发布,请记住,您应该将模板& href参数作为http查询字符串包含在“body”键中。
例如:
$apiCalls[] = array(
"method" => "POST",
"relative_url" => $user['id'] . "/notifications",
"body" => http_build_query(array("href" => $href, "template" => $template, "ref" => "ref_key")),
"access_token" => $app_access_token
);