使用PHP SDK从Facebook Group存储Feed [关闭]

I have a project that needs me to store a group feed of one of my Facebook groups that I want to store locally (MySQL). I have used PHPs Facebook SDK to successfully retrieve and store the first 24 posts. The rest are paginated like, as seen in the response:

"paging": {
    "previous": "https://graph.facebook.com/v2.1/197349856967661/feed?limit=25&since=1413803847&__paging_token=enc_Aezfg88j7xOEW28BENBXvchQql9OYz00t6siBT2MviwZdOCcIFV8nyMyBmrUu39eOHbve68h6yUWLb0Lc12v_HD7k4_q299PnvIq7gz4BAZMZA", 
    "next": "https://graph.facebook.com/v2.1/197349856967661/feed?limit=25&until=1413803553&__paging_token=enc_AeyKAdBaClRXLJ7nBulYeqDEfzW1ovuAXSuDkPMSnbmIxpPXKh24vli0tOpF_OOtnFCXZLNTZki3j2umR8WKKyo3nLmZtICF1zfq7ZASIk2PdQ"
}

I wanted to know if there was a way in which I can loop the same piece of code until all the entries have been stored in my database. I am thinking is there a way to detect if there is a next page and execute another request using the "next" URL? Please do help me. I will highly appreciate it.

Disclaimer: I am going to give you the procedure not the code, you can code it based on what you need.

 login.
 make the first request. //don't handle just yet.
 if (![paging][next]) escapeLoop =1;
 do  //using do .. while
    if (escapeLoop ==1) break; //exits loop if all posts are received in one page
    handle the request   //insert to DB
    make the new request using the link provided in the response.
 while ([paging][next]);
 handle the last request & requests with one page response.