簡體   English   中英

在此代碼中插入fb訪問令牌

[英]Inserting fb access token to this code

我從Google那里獲得了這個腳本,它運行良好,該代碼能夠突然從任何頁面檢索任何Facebook相冊,但它突然停止工作。我在google上進行了研究,發現該代碼中需要訪問令牌實現,但無法執行單獨做任何幫助請考慮

$fb_page_id = "448955931844556";

$json_link = "http://graph.facebook.com/{$fb_page_id}/albums?fields=id,name,description,link,cover_photo,count";
$json = file_get_contents($json_link);

$obj = json_decode($json, true, 512, JSON_BIGINT_AS_STRING);

$album_count = count($obj['data']);
for($x=0; $x<$album_count; $x++){

    $id = $obj['data'][$x]['id'];
    $name = $obj['data'][$x]['name'];
    $description = $obj['data'][$x]['description'];
    $link = $obj['data'][$x]['link'];
    $cover_photo = $obj['data'][$x]['cover_photo'];
    $count = $obj['data'][$x]['count'];

    // if you want to exclude an album, just add the name on the if statement
    if(
        $name!="Profile Pictures" &&
        $name!="Cover Photos" &&
        $name!="Timeline Photos"
    ){

        $show_pictures_link = "photos.php?album_id={$id}&album_name={$name}";

        echo "<div class='col-md-4'>";
            echo "<a href='{$show_pictures_link}'>";
                echo "<img class='img-responsive' style='height:190px;width:190px;' src='https://graph.facebook.com/{$cover_photo}/picture' alt=''>";
            echo "</a>";
            echo "<h3>";
                echo "<a href='{$show_pictures_link}'>{$name}</a>";
            echo "</h3>";

            $count_text="Photo";
            if($count>1){ $count_text="Photos"; }

            echo "<p>";
                echo "<div style='color:#888;'>{$count} {$count_text} / <a href='{$link}' target='_blank'>View on Facebook</a></div>";
                 $description;
            echo "</p>";
        echo "</div>";
    }
}

access_token=<your access token>$json_link

例如:

$fb_access_token = "PUT YOUR ACCESS TOKEN HERE" 
$json_link = "http://graph.facebook.com/{$fb_page_id}/albums?access_token={$fb_access_token}&fields=id,name,description,link,cover_photo,count";

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM