merging multiple pages
-
Hello,
I was wondering if there is way to merge multiple json api and sort by date.I have tried:
//Facebook pages id - somepageid are numbers - this is just an eg. $page1id = 'somepageid1'; $page2id = 'somepageid2'; $page3id = 'somepageid3'; $page4id = 'somepageid4'; //Setup json urls for ids $cff_posts_json_url1 = 'https://graph.facebook.com/'.$page1id.'/' . $graph_query . '?access_token=' . $access_token . '&limit=' . $cff_post_limit . '&locale=' . $cff_locale . $cff_ssl; $cff_posts_json_url2 = 'https://graph.facebook.com/'.$page2id.'/' . $graph_query . '?access_token=' . $access_token . '&limit=' . $cff_post_limit . '&locale=' . $cff_locale . $cff_ssl; $cff_posts_json_url3 = 'https://graph.facebook.com/'.$page3id.'/' . $graph_query . '?access_token=' . $access_token . '&limit=' . $cff_post_limit . '&locale=' . $cff_locale . $cff_ssl; $cff_posts_json_url4 = 'https://graph.facebook.com/'.$page4id.'/' . $graph_query . '?access_token=' . $access_token . '&limit=' . $cff_post_limit . '&locale=' . $cff_locale . $cff_ssl; //Merge json $posts_json1 = cff_fetchUrl($cff_posts_json_url1); $posts_json2 = cff_fetchUrl($cff_posts_json_url2); $posts_json3 = cff_fetchUrl($cff_posts_json_url3); $posts_json4 = cff_fetchUrl($cff_posts_json_url4); $array1 = json_decode($posts_json1, TRUE); $array2 = json_decode($posts_json2, TRUE); $array3 = json_decode($posts_json3, TRUE); $array4 = json_decode($posts_json4, TRUE); $datajson = array_merge($array1, $array2, $array3, $array4); $posts_json = json_encode($datajson);
– I have included these changes with caching and without
– After I save changes, page still renders the same feed like there was no changesConclusion:
I am not looking for solution written in code. I just want to know is it possible and if you could provide guidance I would be thankful.The main reason of doing this is because I want to display all feed posts (4 pages) sorted by date (time) because at the moment it is confusing for readers why some posts are above others that have been posted later.
– this is cos I am displaying 4 pages feed
– eg. second page gets post published while the first page still remains as it was – results in first post from second page having eg. 5 minutes ago (date of publish) while the first page first post has 1 hour ago
– eg.
Page1Post1 1 hour ago
Page2Post1 5 minutes ago
- The topic ‘merging multiple pages’ is closed to new replies.