我在codecanyon上买了一个FB脚本,该脚本允许用户使用facebook按钮登录我的网站。我创建了应用程序,登录部分工作正常。问题是这个脚本还假设让我在我的应用程序的用户的FB墙上发布。那部分不起作用。有些人可以帮我解决这个问题。
我可以通过电子邮件发送给用户,但显然这个人忘了添加FB帖子部分。 这是剧本。
/*
* Created by Ryan Davies, All rights reserved
* http://www.rnrit.co.uk
* Date: Sep 3, 2010
* Time: 12:23:10 PM
*/
ob_start();
session_start();
$output = "";
// include required files
require "../includes/config.php";
require "../includes/database.php";
require "../includes/facebook.php";
require "../includes/language.php";
// check for logged in user
if(isLoggedIn() != "true" || $_SESSION['userType'] != "admin") {
header('Location: login.php');
die();
}
// check for delete user
if(isset($_POST['delID'])) {
$del = new database();
$del->connect();
$where = "id = '" . $_POST['delID'] . "'";
$del->select('username','users',$where);
$result = $del->getResult();
$del->delete('users',$where);
$output = '<div class="ok"><img src="../images/tickbig.png" alt="OK" title="OK" class="float_outside_error"><p>'.outputLan("userAdminPage","user deleted").'</p><script type="text/javascript">hideError();</script></div>';
// delete profile page
unlink('../users/'.$result['username'].'.php');
}
// email all users
if(isset($_POST['emPost'])) {
$errors = 0;
// check input
if($_POST['subject'] == "") { $errors = 1; $output .= '<li>You must enter a subject</li>'; }
if($_POST['from'] == "") { $errors = 1; $output .= '<li>You must enter an email address</li>'; }
if($_POST['reply'] == "") { $errors = 1; $output .= '<li>You must enter a reply to address</li>'; }
if($_POST['message'] == "") { $errors = 1; $output .= '<li>You must enter a message</li>'; }
// check for errors before sending
if($errors == 0) {
// all ok, send message
$message = $_POST['message'];
$message = str_replace("\n.", "\n..", $message);
$subject = $_POST['subject'];
$sender = $_POST['from'];
$reply = $_POST['reply'];
$headers = 'From: ' . $sender . "\r\n" .
'Reply-To: ' . $reply . "\r\n" .
'X-Mailer: PHP/' . phpversion();
// loop through users
$db = new database();
$db->connect();
$where = "contact = 'yes'";
$db->select('*','users');
$result = $db->getResult();
$rows = $db->getRows();
for($i = 0; $i < $rows; $i ++ ) {
$to = $result[$i]['email'];
$name = $result[$i]['name'];
$Nmessage = "";
$Nmessage = "Dear " . $name . "\n\n" . $message;
if(mail($to, $subject, $Nmessage, $headers)) {
// message sent
$output .= '<li>'.outputLan("userAdminPage","email sent") . $to . '</li>';
} else {
// error
$errors = 1;
$output .= '<li>'. outputLan("userAdminPage","email problem") . $to . '</li>';
}
} // end of loop
if($errors == 0) {
$output = '<div class="ok"><img src="../images/tickbig.png" alt="Ok" title="Ok" class="float_outside_error"><ul>'.$output.'</ul><script type="text/javascript">hideError();</script></div>';
} else {
$output = '<div class="error"><img src="../images/crossBig.png" alt="Error" title="Error" class="float_outside_error"><ul>'.$output.'</ul><script type="text/javascript">hideError();</script></div>';
}
} else {
$output = '<div class="error"><img src="../images/crossBig.png" alt="Error" title="Error" class="float_outside_error"><ul>'.$output.'</ul><script type="text/javascript">hideError();</script></div>';
}
} // end of emPost
这是表格
<div id="fb_post">
<h2><img src="../images/facebook.png" alt="fb" title="<?php echo outputLan("userAdminPage","fb image title"); ?>"><?php echo outputLan("userAdminPage","fb post"); ?></h2>
<p><?php echo outputLan("userAdminPage","fb blurb"); ?></p>
<form method="post" action="useradmin.php">
<label for="title"><?php echo outputLan("userAdminPage","post title"); ?></label>
<input type="text" name="title" id="title" class="input_field" size="110">
<label for="name"><?php echo outputLan("userAdminPage","post name"); ?></label>
<input type="text" name="name" id="name" class="input_field" size="110">
<label for="caption"><?php echo outputLan("userAdminPage","post caption"); ?></label>
<input type="text" name="caption" id="caption" class="input_field" size="110">
<label for="desc"><?php echo outputLan("userAdminPage","post body"); ?></label>
<textarea name="desc" id="desc" class="input_field" cols="110" rows="5"></textarea>
<label for="image"><?php echo outputLan("userAdminPage","post image"); ?></label>
<input type="text" name="image" id="image" class="input_field" size="110">
<label for="url"><?php echo outputLan("userAdminPage","post url"); ?></label>
<input type="text" name="url" id="url" class="input_field" size="110">
<input type="submit" name="fbPost" id="fbPost" value="<?php echo outputLan("userAdminPage","post submit"); ?>" class="input_field submit">
</form>
</div>
答案 0 :(得分:0)
确保脚本提示用户输入publish_stream扩展权限。您可以通过单击Facebook按钮登录来判断它是否存在,并且应该说应用程序需要在墙上写入的权限。如果用户未对此进行授权,或者您未要求获得执行此操作的权限,则请求将失败。