문제

최신 Facebook 상태 업데이트를 얻을 수있는 좋은 간단한 PHP 기능을 찾고 있습니다. 하나를 아는 사람이 있습니까?

감사!

편집하다: 아래에 하프 솔루션을 추가했습니다.

아니면 RSS 피드에서 읽을 수있는 좋은 방법을 알고 있다면 최근 상태 업데이트를 뱉어 냈습니까?

도움이 되었습니까?

해결책 9

API 경로를 사용할 수 없었기 때문에 다음에서 찾은 RSS와 함께갔습니다. http://www.new.facebook.com/minifeed.php?filter=11

다음 PHP 기능을 사용했습니다. 상태 프레스라고합니다, 내 자신의 수정 중 일부를 사용하여 Facebook 상태에 대한 RSS 피드를 구문 분석합니다. 잘 작동합니다!

다른 팁

빠른 확인 설립하다 Services_facebook

이것은 불완전한 대답이지만 이것이 지금까지 얻은 것입니다.

첫 번째: FB에 개발자 응용 프로그램을 추가하십시오. 그런 다음 새 응용 프로그램을 만듭니다. 원하는대로 부르십시오.

초: PHP 클라이언트를 다운로드하십시오. Webhost, IE /Facebook /어딘가에 버려

셋째 : PHP 파일로 시작하려면 다음 초보자 코드를 복사하십시오.

 <?php
 require_once('facebook/php/facebook.php');
 $facebook = new Facebook("YOUR_API_KEY","YOUR_SECRET_KEY");
 $result = $facebook->api_client->fql_query("SELECT status FROM user WHERE uid = YOURIDNUMBER");
 // OR --- they both get the same data
 $result = $facebook->api_client->users_getInfo(YOURIDNUMBER,'status');
 print_r($result);
 echo "<pre>Debug:" . print_r($facebook,true) . "</pre>"; // debug info
 ?>

기타 정보 :

  • 로그인하고 응용 프로그램을 추가해야합니다. 또는 응용 프로그램에 오프 라인_access 권한을 부여하고 Application을 추가합니다.
  • 다음 URL을 입력하여 Offline_Access를 추가 할 수 있습니다.http://www.facebook.com/authorize.php?api_key=your_api_key&v=1.0&ext_perm=offline_access
  • 권한에 대한 자세한 정보는 여기에 있습니다. http://wiki.developers.facebook.com/index.php/extended_permissions
  • 나는 정지 지점에있다 : 내 프로그램이 FQL Query 또는 users_getInfo라고 부르는 것은 내 페이지가 PHP 실행을 중지합니까? 새로운 응용 프로그램에 대한 제한된 양의 전화가 있다고 생각합니까? 나는 FB 개발을 한 적이 없어서 완전히 처음입니다. API에 대한 과도한 호출을 방지하기 위해 자신의 DB에 전화를 걸고 최근 상태 (또는 가장 최근 상태)를 저장합니까?

나는 이것이 누군가가 시작하는 데 도움이되기를 바랍니다!

편집하다: Offline_Access가 켜져 있더라도 FB는 귀하가 그 사람이나 친구가 아니라면 (개인 정보 보호 설정에 따라) 누군가가 켜져 있지 않은 것 같습니다.

그러나 마침내 새 프로파일 버전에서 RSS 피드를 찾을 수있었습니다. http://www.new.facebook.com/minifeed.php?filter=11

최신 Facebook 상태를 가져 오는 방법을 찾았습니다. 이것이 당신이하는 방법입니다.

1) Facebook 앱을 만듭니다, 신청서를 비밀 및 응용 프로그램 ID를 복사하십시오.

2) 앱 read_stream 및 offline_access를 프로필에 부여하십시오. (http://developers.facebook.com/docs/authentication/permissions) 최신 상태를 가져 오려면 앱에 Access_Token이 필요합니다. 오프라인_access가 부여되면 Access_Token은 "절대로 만료되지 않아야합니다". 이 작업을 수행하는 가장 쉬운 방법은이 코드에서 생성 된 버튼을 클릭하는 것입니다. ( '앱 ID'를 채우고 쿠키를 true로 설정하십시오!)

<fb:login-button perms="read_stream,offline_access"></fb:login-button>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>FB.init({appId: 'your app id', status: true, cookie: true, xfbml: true});</script>

3) 이제 사용중인 Access_Token을 찾으십시오. Access_token은 FBS_Appid 쿠키에 저장됩니다. 브라우저를 사용하거나 사용하여 찾으십시오 $_COOKIE['fbs_appId']. 찾다 access_token=....

4) 이제 (희망적으로) Access_Token을 만료시키지 않으므로 다음 코드를 사용할 수 있습니다.

$access_token='xxxxxxxxxxxxxxxxxxxx';
$appId='123456789132456789';
$appSecret='xxxxxxxxxxxxxxxxxxxx';
$profileId='123456789';

//http://github.com/facebook/php-sdk/blob/master/src/facebook.php
require 'facebook.php';

$facebook = new Facebook(array('appId' => $appId,'secret' => $appSecret));
$response = $facebook->api('/'.$profileId.'/feed?limit=1&access_token='.$access_token);

5) 메시지 부분이 위치해야합니다. $response['data'][0]['message']

액세스 토큰이 얼마나 오래 유효한지 모르겠습니다. 페이스 북의 말 :

귀하의 응용 프로그램은 언제든지 사용자를 대신하여 공인 요청을 수행 할 수 있습니다. 기본적으로, 대부분의 액세스 토큰은 짧은 기간 후에 만료되어 응용 프로그램이 적극적으로 응용 프로그램을 사용하는 경우 사용자를 대신하여 요청 만 수행 할 수 있도록 만료됩니다. 이 권한은 Oauth Endpoint가 오랫동안 반환 한 액세스 토큰을 만듭니다.

최신 상태를 얻으려면 정말 간단한 기능입니다. Facebook SDK 나 다른 것에 의존하지 않습니다. 컬과 JSON 지원이 필요합니다.

Facebook 상태를 얻는 간단한 PHP 기능

나는 배와 어울리지 않는 것 같지만, 나보다 운이 좋으면 배 솔루션이 장기적으로 가장 좋은 경로로 보인다.

또 다른 아이디어는 다음을 탐구하는 것입니다 Facebook 개발자 API 도서관과 그것이 당신이 찾고있는 것을 줄 수 있는지 확인하십시오.

마지막으로, RSS 피드를 얻는 방법이 있었지만 더 이상 작동하는 지침을 찾을 수는 없지만 Facebook이 관심을 갖는 경우 도움이 될 수 있습니다. 광산은 다음과 같은 것을 보게됩니다.

http://www.new.facebook.com/feeds/status.php?id=[idnumber]&viewer=[viewer]&key=[key]&format=rss20

Jens의 게시물을 사용하여 유효한 Access_Token을 검색했습니다. 그런 다음 다음 코드를 사용하여 상태 메시지와 XML 파일에서 게시 시간을 추출했습니다 ($ 한도를 변경하여 더 많은 상태 메시지를 표시하거나 양식을 사용하여 변경할 수 있습니다).

Facebook ID와 귀하가 만든 앱에서 얻은 액세스 토큰을 넣으십시오 ( Jens의 게시물). 이 스크립트의 출력을 확인할 수 있습니다 여기.

재미있게 보내세요!

<?php
if(isset($_POST['limit'])) {
    $limit = $_POST['limit'];
}
else {
    $limit = 3; // number of status messages to display
}
$f = fopen ("https://api.facebook.com/method/status.get?uid=YOUR_FACEBOOK_ID&limit=".$limit."&access_token=YOUR_ACCESS_TOKEN", "r");

while ($line= htmlentities(fgets($f))) {
    if ($line===FALSE) print ("FALSE\n");
    else
    {
        $content = $content." ".$line;
    }
}
fclose ($f);

$message = explode("&lt;message&gt;", $content); // search for the <message> tag
$message_cnt = count($message);
$msg_index = 0;

$time = explode("&lt;time&gt;", $content); // search for the <time> tag

for($i=1; $i<$message_cnt; $i++)
{
    $tmp = explode("&lt;/message&gt", $message[$i]);
    $msg[$msg_index] = $tmp[0]; // status message

    $tmp2 = explode("&lt;/time&gt", $time[$i]);
    $t[$msg_index++] = $tmp2[0]; // time of posting
}

for($i=0; $i<$msg_index; $i++)
{
     echo("<span class=\"status\">".preg_replace('!\015\012|\015|\012!','<br>',$msg[$i])."</span><br>\n
           <span class=\"date\">on ".date("d.m.Y", $t[$i])." at ".date("H:i",$t[$i])."</span><br><br>\n");

}
?>

나는 지난 며칠 동안 많은 튜토리얼을 시도했지만 그중 어느 것도 효과가 없었습니다. Facebook이 API 요구 사항을 변경했기 때문일 수 있습니다. 이것은 내가 지금 발견 한 유일한 사람입니다.

http://www.deanblog.co.uk/article/13/adding-a-facebook-status-feed-to-website-with-php

phpforfb 프레임 워크 만 사용하십시오 (www.phpforfb.com/en/) 가장 빠른 방법.

코드는 다음과 같습니다.

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**
        }
    }
}
<?php
// see http://github.com/facebook/php-sdk/blob/master/facebook.php
require './facebook.php';
// Create our Application instance.
// see http://www.youtube.com/watch?v=jYqx-RtmkeU for how to get these numbers
$facebook = new Facebook(array('appId' => 'XXX','secret' => 'XXX'));
// This call will always work since we are fetching public data.
// this could be /username or /username/friends etc...
// see developer api for FQL for examples
$status = $facebook->api('/haanmc/feed?limit=1');
?>
<p><?php print $status['data'][0]['message']; ?></p>
<p>Likes: <?php print $status['data'][0]['likes']; ?> | Comments: <?php print count($status['data'][0]['comments']['data']); ?></p>
<textarea style="width: 95%; height: 600px;"><?php print_r($status); ?></textarea>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top