public function onePagePosts()
 {
     $result = array();
     $data = FFFeedUtils::getFeedData($this->url);
     if (sizeof($data['errors']) > 0) {
         $this->errors[] = $data['errors'];
         return array();
     }
     if (isset($data['response']) && is_string($data['response'])) {
         $page = json_decode(html_entity_decode($data['response']));
         if (isset($page->pagination) && isset($page->pagination->next_url)) {
             $this->url = $page->pagination->next_url;
         } else {
             $this->pagination = false;
         }
         foreach ($page->data as $item) {
             $post = $this->parsePost($item);
             if ($this->isSuitablePost($post)) {
                 $result[$post->id] = $post;
             }
         }
     } else {
         $this->errors[] = 'FFInstagram has returned the empty data.';
         error_log('FFInstagram has returned the empty data.');
     }
     return $result;
 }
 private function extendAccessToken($access_token, $facebookAppId, $facebookAppSecret)
 {
     $token_url = "https://graph.facebook.com/oauth/access_token?client_id={$facebookAppId}&client_secret={$facebookAppSecret}&grant_type=fb_exchange_token&fb_exchange_token={$access_token}";
     $response = FFFeedUtils::getFeedData($token_url);
     $response = (string) $response['response'];
     $response = explode('=', $response);
     if (sizeof($response) > 2) {
         $expires = (int) $response[2];
     }
     $access_token = explode('&', $response[1]);
     set_transient(FlowFlow::$PLUGIN_SLUG_DOWN . self::$postfix_at, $access_token[0]);
     set_transient(FlowFlow::$PLUGIN_SLUG_DOWN . self::$postfix_at_expires, isset($expires) ? $expires : 2629743, round($expires / 2));
 }
 private function getPCount($json)
 {
     $count = sizeof($json->data);
     if (isset($json->paging->next)) {
         $data = FFFeedUtils::getFeedData($json->paging->next);
         $count += $this->getPCount(json_decode($data['response']));
     }
     return $count;
 }
 private function setAdditionalInfo()
 {
     $data = FFFeedUtils::getFeedData($this->additionalUrl);
     if (sizeof($data['errors']) > 0) {
         @error_log('Pinterest has errors: ' . $data['errors']);
     } else {
         $response = json_decode($data['response']);
         foreach ($response->data->pins as $pin) {
             $this->pins["http://www.pinterest.com/pin/{$pin->id}/"] = $pin;
         }
     }
 }