0

特定のページが好きな友達を抽出できるこのコードがありますが、特定のページが好きではない友達を抽出する必要があります。

コードは次のとおりです。

$users = $facebook->api(array('method' => 'fql.query',
        'query' => "SELECT uid, first_name, pic_small FROM user WHERE uid IN(
    SELECT uid FROM page_fan WHERE page_id='411133928921438' AND uid IN (
        SELECT uid2 FROM friend WHERE uid1 = me()
    ))"));

OUTER JOIN OR SMTH を使用してこのようなものを取得するにはどうすればよいですか:

$users = $facebook->api(array('method' => 'fql.query',
            'query' => "SELECT uid, first_name, pic_small FROM user WHERE uid NOT IN(
        SELECT uid FROM page_fan WHERE page_id='411133928921438' AND uid IN (
            SELECT uid2 FROM friend WHERE uid1 = me()
        ))"));
4

1 に答える 1

0

OUTER JOINまたはNOT INをサポートしていないので、これを試してください(これが最善の方法かどうかはわかりませんが、うまくいくはずです)

$likes = $facebook->api(array('method' => 'fql.query',
    'query' => "SELECT uid, first_name, pic_small FROM user WHERE uid IN(
SELECT uid FROM page_fan WHERE page_id='411133928921438' AND uid IN (
    SELECT uid2 FROM friend WHERE uid1 = me()
))"));

$allfriends = $facebook->api(array('method' => 'fql.query',
    'query' => "SELECT uid, first_name, pic_small FROM user WHERE uid IN (
    SELECT uid2 FROM friend WHERE uid1 = me()
)"));

// Loop through the rows
// I think there is a page where you can test FQL at developers.facebook.com, I'll see if I can find it on my phone so I can see what the JSON response looks like and fix this code, in the mean while see if this works

// Yeah so the code does this:
// Loop through each item in the $allfriends result, (put the contents of the row into the $friend variable
foreach( $allfriends as $friend )
{  
   // This bit I need to change, this is supposed to look in the $likes array to see if the UID is present, but it will be comparing the uid against the whole object - need to tweak this
   if( !in_array($friend['uid'], $likes) ) 
   {
       // Each friend that doesn't like the page should hit this part of the loop
       echo $friend['uid'];
   }                 
}

免責事項-PHPを使用してから約5年、FQLに触れてから何年も経ちます-何かが機能する/機能しない場合はお知らせください(機能する場合は驚くでしょう:D)

于 2012-05-21T09:47:55.977 に答える