I use facebook graph api to retrieve my facebook posts and display them on my website.
So far I have filtered my post by tags using this code (this code retrieves the FB posts tagged with -fr- / others post are tagged with -en- : which allow me to sort my post by languages)
$string = $post['message'];
$array = array("-fr-");
if(0 < count(array_intersect(array_map('strtolower', explode(' ', $string)), $array)))
First question: I am trying now to retrieve my post based on my language tags PLUS on one another tags.
I have tied:
$array = array("-fr-", "#science");
But all the posts containing EITHER -fr-
OR #science
are display. What I want is to display all the post containing the tags -fr-
AND #science
.
Second question: I would also need to retrieve posts with optional tags. For example I have those posts with these tags:
Post 1= -fr- #science #education
Post 2= -fr- #science #politics
Post 3= -fr- #science #animals
I would like to retrieve only post 1 and 2.
So -fr-
and #science
would be mandatory but #education
and #politics
would be a "EITHER... OR..." request (this request would be like: array("#education", "#politics"); )
Any idea how to do it? Thanks a lot for your help!