我最近使用php开发了一个facebook应用程序。虽然该应用程序适用于所有浏览器,但它不在Safari中,它会在我尝试在用户墙上发布后返回到第一个应用程序步骤。以下是我的代码。
我的应用会显示一个用户朋友列表,并允许其中一个选择朋友,并在他们的墙上发布。
<?php
require ("facebook-api/src/facebook.php");
$facebook = new Facebook(array(
'appId' => '####',
'secret' => '####',
'cookie' => true,
));
// Login or logout url will be needed depending on current user state.
$params = array(
'scope' => 'email,user_birthday,friends_photos,publish_stream',
'redirect_uri' => 'https://apps.facebook.com/appname/'
);
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl($params);
}
$user = $facebook->getUser();
if ($user) {
$friends = $facebook->api('me/friends');
$uids = "";
foreach($friends as $f) {
$uids .= "uid=$f OR ";
}
$user_id_sess = $_SESSION['userid'];
$query_uids = substr($uids,0,strlen($query_uids)-4);
date_default_timezone_set('UTC');
$today = date('m\/d');
$data = $facebook->api(array('method'=>'fql.query','req_perms' => 'friends_birthday','query'=>"select uid,sex,name,birthday from user where uid in (select uid2 from friend where uid1=me()) ORDER by name ASC"));
echo "
<div class='span12 center-align' style='display:none;' id='block3'>
<form id='frmFb' name='frmFb' action='".$_SERVER['PHP_SELF']."' method='post' >
<p><img src='../static/images/logo.png' alt='logo' /></p>
<br />
<h1 style='margin-bottom:10px;'>Share with your friends</h1>
<p id='progress' style='display:none;'><img src='static/img/processing.gif' alt='Processing' /></p>
<div class='center-align well pull-center' style='max-height:300px; overflow:auto;'>
";
foreach($data as $today_bday) {
//$table='user_recipient';
$remfbid = $today_bday['uid'];
$fb_bday = $today_bday['birthday'];
echo "
<div style='width:50px; height:110px; margin:15px; float:left;' class='center-align'>
<a href='#' class='thumbnail'><img src='https://graph.facebook.com/".$today_bday['uid']."/picture' class='friend' alt='".$today_bday['name']."'></a>
<input type='checkbox' name='fbchoose[]' value='".$today_bday['uid']."'>
<p><small>".$today_bday['name']."</small></p>
<br/><br/>
</div>
";
}
echo "
</div>
<br />
<a href='#' class='btn btn-inverse btn-large'><i class='icon-ban-circle icon-white' style='margin-top:4px;'></i> CANCEL</a><input type='submit' value='SHARE NOW' name='btnAddReminder' class='btn btn-success btn-large' onclick='show()'>
</form>
</div>
";
} else {
echo "<p><script>top.location.href='$loginUrl';</script></p>
";
}
?>
<?
if(isset($_REQUEST['btnAddReminder'])){
if($_POST['fbchoose'] == "") {
$error_msg = "<div class='alert pull-center alert-error'><i class='icon-warning-sign' style='margin-top:2px;'></i> Please select at least one friend to share</div><br/>";
}
else {
foreach($_POST['fbchoose'] as $row) {
$vars = array(
'message' => 'Message...',
'name' => 'Name..',
'caption' => 'Caption',
'link' => 'Link',
'description' => 'Description',
'picture' => 'Picture...'
);
$facebook->api("/".$row ."/feed", 'post', $vars);
}
echo "<script>location.href='http://www.mywebsite.com/';</script>";
}
}
?>
答案 0 :(得分:2)
在safari首选项中,在“隐私”下,将“阻止cookie”设置为“从不
”