被困在 Facebook 上发帖
我是 Facebook 应用程序开发的新手,我对如何发布到 Facebook 感到困惑。 我已经阅读了教程,并按照它们进行操作。
这是代码:
<?php
require 'facebook.php';
// Create our Application instance (replace this with your appId and secret).
Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYPEER] = false;
Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYHOST] = 2;
$facebook = new Facebook(array(
'appId' => 'xxx',
'secret' => 'xxx',
'cookie' => true,
));
//Request params
if(!($_GET['code'])) {
header("Location:https://www.facebook.com/dialog/oauth?client_id=xxx&redirect_uri=" . urlencode("http://localhost/facebook/examples/") . "&scope=publish_stream");
//header("Location:http://www.google.com");
exit;
}
$token = $_GET['code'];
echo "token " . $token
$status = $facebook->api('/me/feed', 'POST', array('message' => 'This post came from my app.', 'access_token' => $token));
var_dump($status);
?>
结果:
致命错误:未捕获的 OAuthException:第 543 行 C:\wamp\www\facebook\examples\facebook.php 中抛出错误签名
我错过了什么吗?
I'm new in facebook apps development and I'm get stuck on how to post to facebook.
I've read tutorials, and do according to them.
Here is the code :
<?php
require 'facebook.php';
// Create our Application instance (replace this with your appId and secret).
Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYPEER] = false;
Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYHOST] = 2;
$facebook = new Facebook(array(
'appId' => 'xxx',
'secret' => 'xxx',
'cookie' => true,
));
//Request params
if(!($_GET['code'])) {
header("Location:https://www.facebook.com/dialog/oauth?client_id=xxx&redirect_uri=" . urlencode("http://localhost/facebook/examples/") . "&scope=publish_stream");
//header("Location:http://www.google.com");
exit;
}
$token = $_GET['code'];
echo "token " . $token
$status = $facebook->api('/me/feed', 'POST', array('message' => 'This post came from my app.', 'access_token' => $token));
var_dump($status);
?>
Result:
Fatal error: Uncaught OAuthException: Bad signature thrown in C:\wamp\www\facebook\examples\facebook.php on line 543
Did I miss something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,您正在使用原始 OAuth 登录,同时使用 facebook php SDK。
如果您一直使用 SDK,请不要这样做:
SDK 将自行处理令牌;)
Ok, you are using raw OAuth login and at the same time using facebook php SDK.
Don't do it like that, if you are using SDK us it all the way:
SDK will handle token him self ;)