[英]PHP SDK Facebook get message to all friends
Hello I have some code but I want to add something to it, I want to post something to ALL my friends walls to give them all a message how can I do this?你好,我有一些代码,但我想添加一些东西,我想在我所有的朋友墙上张贴一些东西给他们一个消息,我该怎么做? So I want to log in with my account and post to all my friends just with 1 click, is there a way to do this or any other way to get my friends attentions to my message?所以我想用我的帐户登录并通过 1 次点击发布给我所有的朋友,有没有办法做到这一点或任何其他方式让我的朋友关注我的消息? here is my current code.这是我当前的代码。
<?php
session_start();
// added in v4.0.0
require_once 'autoload.php';
use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;
use Facebook\Entities\AccessToken;
use Facebook\HttpClients\FacebookCurlHttpClient;
use Facebook\HttpClients\FacebookHttpable;
// init app with app id and secret
FacebookSession::setDefaultApplication( '**********' , '**********' );
// login helper with redirect_uri
$helper = new FacebookRedirectLoginHelper('http://centralrp.co.uk/ashisawesome/fbconfig.php' );
try {
$session = $helper->getSessionFromRedirect();
} catch( FacebookRequestException $ex ) {
// When Facebook returns an error
} catch( Exception $ex ) {
// When validation fails or other local issues
}
// see if we have a session
if ( isset( $session ) ) {
// graph api request for user data
$request = new FacebookRequest( $session, 'GET', '/me' );
$response = $request->execute();
// get response
$graphObject = $response->getGraphObject();
$fbid = $graphObject->getProperty('id'); // To Get Facebook ID
$fbfullname = $graphObject->getProperty('name'); // To Get Facebook full name
$femail = $graphObject->getProperty('email'); // To Get Facebook email ID
/* ---- Session Variables -----*/
$_SESSION['FBID'] = $fbid;
$_SESSION['FULLNAME'] = $fbfullname;
$_SESSION['EMAIL'] = $femail;
/* ---- header location after session ----*/
header("Location: index.php");
} else {
$loginUrl = $helper->getLoginUrl();
header("Location: ".$loginUrl);
}
?>
<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<title>Login with Facebook</title>
<link href="http://www.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet">
</head>
<body>
<?php if ($_SESSION['FBID']): ?> <!-- After user login -->
<div class="container">
<div class="hero-unit">
<h1>Hello <?php echo $_SESSION['USERNAME']; ?></h1>
<p>Welcome to "facebook login" tutorial</p>
</div>
<div class="span4">
<ul class="nav nav-list">
<li class="nav-header">Image</li>
<li><img src="https://graph.facebook.com/<?php echo $_SESSION['FBID']; ?>/picture"></li>
<li class="nav-header">Facebook ID</li>
<li><?php echo $_SESSION['FBID']; ?></li>
<li class="nav-header">Facebook fullname</li>
<li><?php echo $_SESSION['FULLNAME']; ?></li>
<li class="nav-header">Facebook Email</li>
<li><?php echo $_SESSION['EMAIL']; ?></li>
<div><a href="logout.php">Logout</a></div>
</ul></div></div>
<?php else: ?> <!-- Before login -->
<div class="container">
<h1>Login with Facebook</h1>
Not Connected
<div>
<a href="fbconfig.php">Login with Facebook</a></div>
<div> <a href="http://www.krizna.com/general/login-with-facebook-using-php/" title="Login with facebook">View Post</a>
</div>
</div>
<?php endif ?>
</body>
</html>
That´s not possible at all for obvious reasons: It would be pure spam.由于显而易见的原因,这根本不可能:这将是纯粹的垃圾邮件。
You can only post to your own wall with the API, and you have to go through a preview process with the require permission, so Facebook can check if you don´t spam.您只能使用 API 发布到您自己的墙,并且您必须通过需要权限的预览过程,以便 Facebook 可以检查您是否没有垃圾邮件。 You should consider reading the platform policy before creating any App.在创建任何应用程序之前,您应该考虑阅读平台政策。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.