0

我最近使用 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>";

    }
    }
    ?>
4

1 回答 1

2

在 Safari 偏好设置中,在“隐私”下,将“阻止 cookie”设置为从不

于 2012-07-10T07:49:46.990 回答