在 Facebook API 中按生日日期排序我的朋友列表? [英] Sorting by birthday date my friend list in Facebook API?

查看:16
本文介绍了在 Facebook API 中按生日日期排序我的朋友列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建自己的应用程序来显示即将到来的朋友的生日.我有权从 facebook 获取此日期,并且我正在我的网站上显示我所有朋友的出生日期.我唯一的问题是如何显示 ie.前 10 个即将到来的生日?我正在使用 $facebook->api('/me/friends?limit=10) 但不知道如何对它们进行排序.有人帮忙吗?我应该尝试对哪些代码进行排序?一些 facebook api 代码或 php 代码.如果是 php 那么也许你有一些如何做到这一点的技巧.干杯!

解决方案

我自己解决了这个问题.很简单的解决方案......也许太简单了,但效果很好.那是我的代码.也许它可以帮助将来的某个人;)

$fql_n = "SELECT uid, name,birth_date FROM user WHERE uid IN (SELECT uid2 FROMfriend WHERE uid1 = me()) AND strlen(birthday_date) != 0 ORDER BYbirthday_date";$param = 数组('方法' =>'fql.query','查询' =>$fql_n,'回调' =>'');$fqlResultt = $facebook->api($parame);$ile_dat = 0;$miesiace_slownie = array("01" => "jan", "02" => "feb", "03" => "mar", "04" => "apr", "05" =>; "may", "06" => "jun", "07" => "jul", "08" => "aug", "09" => "sep", "10" =>; "oct", "11" => "nov", "12" => "dec");如果($ fqlResultt){foreach($fqlResultt 作为 $ress){$data = date("m/d");列表($fb_m,$fb_d)=爆炸(/",$ress['birthday_date']);$fb_date = $fb_m."/".$fb_d;if($data<=$fb_date) { ?><div class="fb_birthday_fr"><span class="fb_brt_day"><?php echo $fb_d .' ' .$miesiace_slownie[$fb_m];?></span><span class="fb_brt_fr"><?php echo $ress['name'];?></span>

<?php$ile_dat++;if($ile_dat == 6) 中断;}}}

$miesiace_slownie 是一个数组,用于将来自 facebook 的月份数据转换为本地语言类型.

干杯,非常感谢 ^Love Sharma 给予的帮助.啤酒给你;)

I'm creating my own application to show forthcoming friend's birthday. I have a permission to get this dates from facebook and i'm displaying all my friends with their date of birth on my site. My only question is how to display ie. first 10 forthcoming birthdays? i'm using $facebook->api('/me/friends?limit=10) but have not idea how to sort them. Anyone help? Which code should i try to sort them? some facebook api code or php code. if php then maybe you have some tips how to do this.Cheers!

解决方案

i've resolve the problem by myself. quite simple solutions... maybe too simple but works perfect. That's my code. maybe it help someone in future ;)

$fql_n    = "SELECT uid, name, birthday_date FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND strlen(birthday_date) != 0 ORDER BY birthday_date";

    $parame  =   array(
           'method'     => 'fql.query',
            'query'     => $fql_n,
          'callback'    => ''
    );
    $fqlResultt   =   $facebook->api($parame);
    $ile_dat = 0;

    $miesiace_slownie = array("01" => "jan", "02" => "feb", "03" => "mar", "04" => "apr", "05" => "may", "06" => "jun", "07" => "jul", "08" => "aug", "09" => "sep", "10" => "oct", "11" => "nov", "12" => "dec");
    if($fqlResultt){
        foreach($fqlResultt as $ress){
            $data = date("m/d");
            list($fb_m,$fb_d) = explode("/", $ress['birthday_date']);
            $fb_date = $fb_m."/".$fb_d;
            if($data<=$fb_date) { ?>
                <div class="fb_birthday_fr">
                    <span class="fb_brt_day"><?php echo $fb_d . ' ' . $miesiace_slownie[$fb_m]; ?></span>
                    <span class="fb_brt_fr"><?php echo $ress['name']; ?></span>
                </div>
                <?php
                $ile_dat++;
                if($ile_dat == 6) break;
            }


        }
    }

$miesiace_slownie is a array that's convert month data from facebook into local language type.

cheers and many thanks ^Love Sharma for given help. Beer for you ;)

这篇关于在 Facebook API 中按生日日期排序我的朋友列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆