PHP function to get Facebook status?

前端 未结 10 1820
甜味超标
甜味超标 2020-12-08 12:30

I\'m looking for a good, simple PHP function to get my latest Facebook status updates. Anyone know of one?

Thanks!

EDIT: I\'ve added a half

10条回答
  •  佛祖请我去吃肉
    2020-12-08 13:02

    Just use PHPforFB framework (www.phpforfb.com/en/) for the fastest way.

    The code looks like this:

    require_once('phpforfb_framework.php');
    
    $structInit = array('app_id' => APP_ID,'app_name' => APP_NAME,'sec_key' => APP_SECKEY);
    
    $FacebookAPP = new PHPforFB($structInit);
    
    if($FacebookAPP->lastErrorCode>0){
        //Creation failed => Display error message and exit
        echo "PHPforFB Error: ".$FacebookAPP->lastErrorCode." -> ".$FacebookAPP->lastError;
    }else{
        //PHPforFB framework established
    
        if($FacebookAPP->userLoggedIn === TRUE){
    
            //If the user is logged in at Facebook:
            //Here you can determine if the user has at least once before
            //granted basic permissions to your application.
            if($FacebookAPP->userAuthenticated === FALSE){
    
                //The user has not yet granted permissions
                //**your code here**
            }else{
                //The user has already granted permissions, therefore his Facebook ID
                //is known to us. It is always available in $FacebookAPP->userID:
    
                $userID = $FacebookAPP->userID;
                //**your code here**
            }
        }
    }
    

提交回复
热议问题