例やテスト ケースも、使用する API コードも提供しませんでした。例として、Facebook User Name Hostessの次のリンクを使用します ( Twinkies 万歳! )。
メイン:https
://www.facebook.com/Hostessフォトアルバム:https ://www.facebook.com/Hostess/photos_albums
まず、Facebook ユーザー番号が必要です。要求
を実行するか、ブラウザに次のように入力できます: Facebook ユーザー情報: http://graph.facebook.com/HostessGET
この例を続けるには、前のステップで提供された Facebook 番号を使用します:
Facebook ID: 145369525544570
Facebook を使用していないユーザーと共有できる Facebook API (graph/fql) を介して Facebook アルバムの公開リンクを取得する方法はありますか?
はい、方法があります!このリンクはjson
、すべてのアルバムの結果を提供します。この場合は 6:
Facebook Albums via json
: http://graph.facebook.com/145369525544570/albums
返される結果を制限するには、以下を使用できます?limit=1
(1 は返されるアルバムの数です):
Facebook Album (1) via json
: http://graph.facebook.com/145369525544570/albums?limit=1
このアルバムは一般公開されていません。ユーザーが設定したアルバムの共有権限によって制限されます。しかし、この制限付きアルバムの公開リンクを生成して、このリンクを送信された人は誰でも無条件にアルバムを表示できるようにする方法を探しています.
あなたは運が悪く、方法はありません。ただし、アルバム内の画像を表示するために Facebook メンバーである必要はありません。json
前のステップのデータを使用すると、アルバムが公開されるときに機能します。簡単なGET
リクエストを使用するだけです:
jsFiddle DEMO: Facebook ID からの Facebook アルバム リンク
// Console log messages are provided, activate your browsers console.
$.ajax({
url: 'http://graph.facebook.com/145369525544570/albums',
dataType: "json",
success: function(yourVar) {
// Make sure the request, 1 json object, was returned.
if (yourVar) {
console.log('This is the jQuery Object received. Click on it to explore contents');
console.log(yourVar);
// This will parse the Objects received in 'data' variable.
// Having said that, it's coincidental the data the wrapped in a 'data' name.
$(yourVar.data).each(function(index) {
// Only process Objects that have valid Album links.
// Having said that, only Photo Albums are returned in initial data, not Video Albums.
if(this.link){
// Display in console the jQuery zero indexed number
console.info('Album Index object: ' + index);
//
// Display in HTML via append, the same information.
$('body').append('<b>Album Index Object: </b>' + index + '<br />');
// Display in console the Album Names available
console.info('Name: ' + this.name);
//
// Display in HTML via append, the same information.
$('body').append('<b>Name: </b>' + this.name + '<br />');
// Display in console the Album Name Url;
console.log('Url: ' + this.link);
//
// Display in HTML via append, the same information.
$('body').append('<b>Url: </b>' + this.link + '<br />');
// Display in console dashed lines before next item is shown.
console.log('-------');
//
// Display in HTML via append, the same information.
$('body').append('<hr><br /><br />');
}
});
} else {
console.log('Was data expected? Check your jQuery or JavaScript for errors.');
}
}
});
// Power-Tip!
// You can also use .ajax() with a YQL Rest Query url.
// See YQL Console with Rest Statement at:
// http://developer.yahoo.com/yql/console/?q=SELECT%20data.link%20FROM%20json%20WHERE%20url%3D%22https%3A%2F%2Fgraph.facebook.com%2F145369525544570%2Falbums%22&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys
// As seen there, the data.link is providing just the links.
// Change data.link to * to see all data nodes available in json tree.
// That being said, your .ajax() url for above is at the bottom: The Rest Query.