English 中文(简体)
Facebook和php-如何将内容从我的网站发布到我的Facebook墙?
原标题:Facebook and php - how to post content from my site to my facebook wall?
  • 时间:2011-06-01 14:29:09
  •  标签:
  • php
  • facebook

我对这个facebook api很困惑。

我的数据库中有facebook用户名和密码,我想签名并将内容从我的网站发布到我的facebook墙上。我该怎么做?

我已经下载了facebookphp-sdk,只需要能够在我的php文件中包含“post”部分就可以了,我现在有这段代码

require_once ( facebook.php );
                $app_id = "MY_ID";
                $app_secret = "MY_SECRET";
                $facebook = new Facebook(array( appId  => $app_id,  secret  => $app_secret,  cookie  => true));

                if(is_null($facebook->getUser())) {

                    header("Location:{$facebook->getLoginUrl(array( req_perms  =>  user_status,publish_stream,user_photos ))}");
                    exit;
                } 

                $status = $facebook->api( /me/feed ,  POST , array( message  => utf8_encode($my_message)));

有了这个,我只是得到了一个内部服务器错误,没有更多的东西知道我做错了什么。。。

even with var_dump($status) I get nothing Thanks

问题回答

您不能以用户身份登录Facebook Graph API。你一开始就不应该要求任何用户的Facebook密码,这就是为什么Facebook不允许这样做的原因。

API允许您作为应用程序登录,Facebook用户可以授予该应用程序权限。您需要在https://www.facebook.com/developers/apps.php

完成后,您可以提示用户在墙上张贴,或使用http://developers.facebook.com/docs/reference/dialogs/feed/

首先尝试(我希望您输入了$app_id和$app_secret):

require_once ( facebook.php );
$app_id = "MY_ID";
$app_secret = "MY_SECRET";
$facebook = new Facebook(array( appId  => $app_id,  secret  => $app_secret,  cookie  => true));
$user = $facebook->getUser();

var_export($user);

如果您正确登录,您应该使用数据。

你也许应该看看这个页面作为一个例子Facebook Graph API PHP SDK在页面上发布为页面





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签