大家好我想从Facebook用户专辑中获取所有数据。我运行查询: -
SELECT src_big, caption, src_small, src FROM photo WHERE owner = OWNER_ID AND aid = 'ALBUM_ID'
我收到了以下错误: -
{
"error": {
"message": "Your statement is not indexable. The WHERE clause must contain an indexable column. Such columns are marked with * in the tables linked from http://developers.facebook.com/docs/reference/fql ",
"type": "NoIndexFunctionException",
"code": 604
}
}
请参阅sceenshot: -
当我搜索时,我得到了这个解决方案FQL Your statement is not indexable, but fine in console,但它不起作用
编辑: - 我尝试了以下代码
<?php
require 'facebook.php';
$facebook = new Facebook(array(
'appId' => 'APP_ID',
'secret' => 'SECRET_KEY',
'cookie' => true,
));
$fql = "SELECT aid FROM album WHERE aid = 'ALBUM_ID' ";
$response = $facebook->api(array(
'method' => 'fql.query',
'query' =>$fql,
));
print_r($response);
?>
但它返回空数组Array()
编辑1: -
我在下面尝试了一些事情
查询: - SELECT pid,src_big,owner,link,position,created,caption,src FROM photo WHERE aid="ALBUM_ID"
编辑2: -
我尝试了以下代码并且我得到了所有图片,但问题是当我使用我的朋友ownerid然后它返回结果但是当我使用我的id然后它返回空为什么?
<?php
ob_start();
require 'facebook.php';
$facebook = new Facebook(array(
'appId' => 'APP_ID',
'secret' => 'SECRET_KEY',
'cookie' => true,
));
$fql = "select aid,cover_pid,description,created,name,photo_count from album where owner=OWNER_IDorder by created desc limit 10";
$result = $facebook->api(array(
'method'=>'fql.query',
'query'=>$fql
));
for($i=0;$i<sizeof($result);$i++){
$fql = "select images,created,link,pid,src_big,src_big_width,src_big_height from photo where aid='".$result[$i]['aid']."'";
$ret = $facebook->api(array(
'method'=>'fql.query',
'query'=>$fql
));
for($j=0;$j<sizeof($ret);$j++){
echo '<img src="'.$ret[$j]['src_big'].'"></img> ('.$ret[$j]['created'].')';
echo '<br>';
}
echo '-----------------------------------------------------------------------------<br><br>';
}
?>
我做错了,请帮帮我。提前谢谢。
答案 0 :(得分:0)
首先,您使用图谱API 在Graph API资源管理器中尝试了您的查询;您应该在 FQL查询控制台中测试它。
第二件事,我并没有真正展示如何获得aid
,但它实际上不是你从facebook api获得的专辑ID。您应该在查询中使用album_object_id
来获取照片。
您的查询将是:
SELECT src_big, caption, src_small, src FROM photo WHERE owner = OWNER_ID AND album_object_id = 'ALBUM_ID'
P.S。我在FQL Explorer中尝试过,它工作正常!
答案 1 :(得分:0)
由于这是Facebook的许可问题所以我通过要求用户允许访问他/她的个人资料,照片等来解决这个问题,如果用户接受它,那么通过使用以下代码,我可以获得他的Facebook照片。< / p>
<?php
ob_start();
require 'facebook.php';
@session_start();
include_once('config.php');
$facebook = new Facebook(array(
'appId' => APP_ID,
'secret' => SECRET_KEY,
'cookie' => true,
));
$fql = "select aid,cover_pid,description,created,name,photo_count from album where owner=me() order by created desc limit 10";
$result = $facebook->api(array(
'method'=>'fql.query',
'query'=>$fql
));
for($i=0;$i<sizeof($result);$i++){
$fql = "select images,created,link,pid,src_big,src_big_width,src_big_height from photo where aid='".$result[$i]['aid']."'";
$ret = $facebook->api(array(
'method'=>'fql.query',
'query'=>$fql,
'scope'=>'user_photos'
));
$k = 1;
for($j=0;$j<sizeof($ret);$j++){
echo '<div>';
echo '<img src="'.$ret[$j]['src_big'].'" id="img'.$k.'"></img>';
echo '<input type="checkbox" class="select_img" current_check = "'.$k.'" name="image_checkbox">';
echo '</div>';
$k++;
}
}
?>