我最近開發了一個使用php的facebook應用程序。儘管該應用在所有瀏覽器中都能正常工作,但它並未在Safari中使用,但在我嘗試在用戶牆上發帖後,它會將我返回到第一個應用步驟。以下是我的代碼。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>";
}
}
?>
[Safari瀏覽器的第三方cookie的iframe的伎倆不再工作?(HTTP的可能重複://facebook.stackoverflow。 com/questions/9930671/safari-3rd-party-cookie-iframe-trick-no-longer-working) – Igy 2012-07-10 07:55:07