2012-07-10 71 views
0

我最近開發了一個使用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>"; 

    } 
    } 
    ?> 
+0

[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

回答

2

在Safari偏好, 「隱私」 下,設置 「阻止Cookie」 從不

+0

有沒有辦法以編程的方式來做,因爲我不能要求用戶改變Safari的偏好設置。 – 2012-07-10 08:11:40

+1

@tamal我們使用的信息圖像只針對safari用戶[鏈接] http://cl.ly/451T0P1Z352a3R1o3u1o – vedran 2012-07-10 08:58:12

+0

感謝您的回答Vedran!它爲我結束了一個頭痛的問題! – 2013-11-25 10:06:32

相關問題