Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/flow-flo.../libs/flowflow/social/src/flow/social
File: FFFacebook.php
<?php namespace flow\social;
[0] Fix | Delete
if ( ! defined( 'WPINC' ) ) die;
[1] Fix | Delete
[2] Fix | Delete
use Exception;
[3] Fix | Delete
use flow\social\cache\LAFacebookCacheManager;
[4] Fix | Delete
use stdClass;
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Flow-Flow.
[8] Fix | Delete
*
[9] Fix | Delete
* @package FlowFlow
[10] Fix | Delete
* @author Looks Awesome <email@looks-awesome.com>
[11] Fix | Delete
[12] Fix | Delete
* @link http://looks-awesome.com
[13] Fix | Delete
* @copyright Looks Awesome
[14] Fix | Delete
*/
[15] Fix | Delete
class FFFacebook extends FFHttpRequestFeed implements LAFeedWithComments {
[16] Fix | Delete
const API_VERSION = 'v3.3';
[17] Fix | Delete
[18] Fix | Delete
/** @var string | bool */
[19] Fix | Delete
private $accessToken;
[20] Fix | Delete
/** @var LAFacebookCacheManager */
[21] Fix | Delete
private $facebookCache;
[22] Fix | Delete
[23] Fix | Delete
/** @var bool */
[24] Fix | Delete
private $hideStatus = true;
[25] Fix | Delete
private $image;
[26] Fix | Delete
private $media;
[27] Fix | Delete
private $carousel = [];
[28] Fix | Delete
private $images;
[29] Fix | Delete
[30] Fix | Delete
private $new_post_ids;
[31] Fix | Delete
[32] Fix | Delete
public function __construct() {
[33] Fix | Delete
parent::__construct( 'facebook' );
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
public function init( $context, $feed ) {
[37] Fix | Delete
parent::init( $context, $feed );
[38] Fix | Delete
$this->facebookCache = $this->context['facebook_cache'];
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* @param $item
[43] Fix | Delete
*
[44] Fix | Delete
* @return array
[45] Fix | Delete
* @throws Exception, LASocialRequestException
[46] Fix | Delete
*/
[47] Fix | Delete
public function getComments($item) {
[48] Fix | Delete
if (is_object($item)){
[49] Fix | Delete
$result = [];
[50] Fix | Delete
if (isset($item->comments->data)){
[51] Fix | Delete
foreach ($item->comments->data as $comment){
[52] Fix | Delete
$result[] = $this->getComment($comment);
[53] Fix | Delete
}
[54] Fix | Delete
}
[55] Fix | Delete
return $result;
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
$objectId = $item;
[59] Fix | Delete
$accessToken = $this->facebookCache->getAccessToken();
[60] Fix | Delete
if ($this->accessToken === false){
[61] Fix | Delete
$this->errors[] = $this->facebookCache->getError();
[62] Fix | Delete
throw new Exception();
[63] Fix | Delete
}
[64] Fix | Delete
$api = FFFacebook::API_VERSION;
[65] Fix | Delete
$url = "https://graph.facebook.com/{$api}/{$objectId}/comments?total_count={$this->getCount()}&access_token={$accessToken}";
[66] Fix | Delete
[67] Fix | Delete
$request = $this->getFeedData($url);
[68] Fix | Delete
$json = json_decode($request['response']);
[69] Fix | Delete
[70] Fix | Delete
if (!is_object($json) || (is_object($json) && sizeof($json->data) == 0)) {
[71] Fix | Delete
if (isset($request['errors']) && is_array($request['errors'])){
[72] Fix | Delete
if (!empty($request['errors'])){
[73] Fix | Delete
foreach ( $request['errors'] as $error ) {
[74] Fix | Delete
$error['type'] = 'facebook';
[75] Fix | Delete
$this->errors[] = $error;
[76] Fix | Delete
throw new Exception();
[77] Fix | Delete
}
[78] Fix | Delete
}
[79] Fix | Delete
}
[80] Fix | Delete
else {
[81] Fix | Delete
$this->errors[] = ['type'=>'facebook', 'message' => 'Bad request, access token issue. <a href="http://docs.social-streams.com/article/55-400-bad-request" target="_blank">Troubleshooting</a>.', 'url' => $url];
[82] Fix | Delete
throw new Exception();
[83] Fix | Delete
}
[84] Fix | Delete
return [];
[85] Fix | Delete
}
[86] Fix | Delete
else {
[87] Fix | Delete
if($json->data){
[88] Fix | Delete
// return first 5 comments
[89] Fix | Delete
$data = array_slice($json->data, 0, 5);
[90] Fix | Delete
$result = [];
[91] Fix | Delete
foreach ($data as $item){
[92] Fix | Delete
$result[] = $this->getComment($item);
[93] Fix | Delete
}
[94] Fix | Delete
return $result;
[95] Fix | Delete
}else{
[96] Fix | Delete
$this->errors[] = [
[97] Fix | Delete
'type' => 'facebook',
[98] Fix | Delete
'message' => 'Comments issue',
[99] Fix | Delete
'url' => $url
[100] Fix | Delete
];
[101] Fix | Delete
throw new Exception();
[102] Fix | Delete
}
[103] Fix | Delete
}
[104] Fix | Delete
}
[105] Fix | Delete
[106] Fix | Delete
protected function deferredInit($feed) {
[107] Fix | Delete
$this->images = [];
[108] Fix | Delete
if (isset($feed->{'timeline-type'})) {
[109] Fix | Delete
$timeline = $feed->{'timeline-type'} == 'user_timeline' ? 'page_timeline' : $feed->{'timeline-type'};
[110] Fix | Delete
$locale = defined('FF_LOCALE') ? 'locale=' . FF_LOCALE : 'locale=en_US';
[111] Fix | Delete
$api = FFFacebook::API_VERSION;
[112] Fix | Delete
switch ($timeline) {
[113] Fix | Delete
case 'group':
[114] Fix | Delete
case 'feed':
[115] Fix | Delete
$groupId = (string)$feed->content;
[116] Fix | Delete
$fields = 'fields=';
[117] Fix | Delete
$fields = $fields . 'likes.summary(true),comments.summary(true),shares,';
[118] Fix | Delete
$fields = $fields . 'id,created_time,from,message,picture,full_picture,attachments{media,subattachments},status_type,story';
[119] Fix | Delete
$this->url = "https://graph.facebook.com/{$api}/{$groupId}/feed?{$fields}&limit={$this->getCount()}&{$locale}";
[120] Fix | Delete
$this->hideStatus = false;
[121] Fix | Delete
break;
[122] Fix | Delete
case 'page_timeline':
[123] Fix | Delete
$page_id = (string)$feed->content;
[124] Fix | Delete
[125] Fix | Delete
try {
[126] Fix | Delete
$request = $this->getFeedData("https://graph.facebook.com/{$api}/me/accounts?access_token={$this->accessToken}");
[127] Fix | Delete
$json = json_decode($request['response']);
[128] Fix | Delete
if($json->data) {
[129] Fix | Delete
foreach ( $json->data as $item ) {
[130] Fix | Delete
if (($page_id == $item->id) || ($page_id == $item->name)) {
[131] Fix | Delete
$this->accessToken = $item->access_token;
[132] Fix | Delete
$page_id = 'me';
[133] Fix | Delete
break;
[134] Fix | Delete
}
[135] Fix | Delete
}
[136] Fix | Delete
}
[137] Fix | Delete
}
[138] Fix | Delete
catch (LASocialRequestException $exception){
[139] Fix | Delete
error_log($exception->getMessage());
[140] Fix | Delete
}
[141] Fix | Delete
[142] Fix | Delete
$fields = 'fields=';
[143] Fix | Delete
$fields = $fields . 'likes.summary(true),comments.summary(true),shares,permalink_url,';
[144] Fix | Delete
$fields = $fields . 'id,created_time,from,message,picture,full_picture,status_type,story';
[145] Fix | Delete
if ($page_id !== 'raffylochermanagement'){
[146] Fix | Delete
$fields = $fields . ',attachments';
[147] Fix | Delete
}
[148] Fix | Delete
$this->url = "https://graph.facebook.com/{$api}/{$page_id}/posts?{$fields}&limit={$this->getCount()}&{$locale}";
[149] Fix | Delete
$this->hideStatus = false;
[150] Fix | Delete
break;
[151] Fix | Delete
case 'album':
[152] Fix | Delete
$fields = 'fields=';
[153] Fix | Delete
$fields = $fields . 'likes.summary(true),comments.summary(true),';
[154] Fix | Delete
$fields = $fields . 'id,created_time,from,link,name,picture,source';
[155] Fix | Delete
$albumId = (string)$feed->content;
[156] Fix | Delete
$this->url = "https://graph.facebook.com/{$api}/{$albumId}/photos?{$fields}&limit={$this->getCount()}&{$locale}";
[157] Fix | Delete
$this->hideStatus = false;
[158] Fix | Delete
break;
[159] Fix | Delete
default:
[160] Fix | Delete
$fields = 'fields=';
[161] Fix | Delete
$fields = $fields . 'likes.summary(true),comments.summary(true),shares,';
[162] Fix | Delete
$fields = $fields . 'id,created_time,from,link,message,name,object_id,picture,full_picture,attachments{media,subattachments},source,status_type,story';
[163] Fix | Delete
$this->url = "https://graph.facebook.com/{$api}/me/home?{$fields}&limit={$this->getCount()}&{$locale}";
[164] Fix | Delete
}
[165] Fix | Delete
}
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
protected function beforeProcess() {
[169] Fix | Delete
$this->accessToken = $this->facebookCache->getAccessToken();
[170] Fix | Delete
if ($this->accessToken === false){
[171] Fix | Delete
$this->errors[] = $this->facebookCache->getError();
[172] Fix | Delete
return false;
[173] Fix | Delete
}
[174] Fix | Delete
$this->facebookCache->startCounter();
[175] Fix | Delete
return true;
[176] Fix | Delete
}
[177] Fix | Delete
[178] Fix | Delete
protected function afterProcess( $result ) {
[179] Fix | Delete
$this->facebookCache->stopCounter();
[180] Fix | Delete
return parent::afterProcess( $result );
[181] Fix | Delete
}
[182] Fix | Delete
[183] Fix | Delete
protected function getUrl() {
[184] Fix | Delete
return $this->getUrlWithToken($this->url);
[185] Fix | Delete
}
[186] Fix | Delete
[187] Fix | Delete
protected function items( $request ) {
[188] Fix | Delete
$pxml = json_decode($request);
[189] Fix | Delete
if (isset($pxml->data)) {
[190] Fix | Delete
$ids = $this->facebookCache->getIdPosts($this->id());
[191] Fix | Delete
$new_ids = [];
[192] Fix | Delete
foreach ( $pxml->data as $item ) {
[193] Fix | Delete
$new_ids[] = $this->getId($item);
[194] Fix | Delete
}
[195] Fix | Delete
$this->new_post_ids = [];
[196] Fix | Delete
$diff = array_diff($new_ids, $ids);
[197] Fix | Delete
foreach ( $diff as $id ) {
[198] Fix | Delete
$this->new_post_ids[$id] = 1;
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
return $pxml->data;
[202] Fix | Delete
}
[203] Fix | Delete
return [];
[204] Fix | Delete
}
[205] Fix | Delete
[206] Fix | Delete
protected function isSuitableOriginalPost( $post ) {
[207] Fix | Delete
if ($this->hideStatus) return false;
[208] Fix | Delete
if (isset($post->status_type) && $post->status_type == 'tagged_in_photo') return false;
[209] Fix | Delete
if (!isset($post->created_time)) return false;
[210] Fix | Delete
[211] Fix | Delete
$hasLimit = $this->facebookCache->hasLimit();
[212] Fix | Delete
if (!$hasLimit){
[213] Fix | Delete
$this->errors[] = [
[214] Fix | Delete
'type' => 'facebook',
[215] Fix | Delete
'message' => 'Your site has hit the Facebook API rate limit. <a href="http://docs.social-streams.com/article/133-facebook-app-request-limit-reached" target="_blank">Troubleshooting</a>.'
[216] Fix | Delete
];
[217] Fix | Delete
}
[218] Fix | Delete
return $hasLimit;
[219] Fix | Delete
}
[220] Fix | Delete
[221] Fix | Delete
protected function prepare( $item ) {
[222] Fix | Delete
$this->image = null;
[223] Fix | Delete
$this->media = null;
[224] Fix | Delete
return parent::prepare( $item );
[225] Fix | Delete
}
[226] Fix | Delete
[227] Fix | Delete
protected function getHeader($item){
[228] Fix | Delete
if (isset($item->status_type) && $item->status_type == 'added_photos'){
[229] Fix | Delete
return '';
[230] Fix | Delete
}
[231] Fix | Delete
if (isset($item->name)){
[232] Fix | Delete
return $item->name;
[233] Fix | Delete
}
[234] Fix | Delete
return '';
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
protected function showImage($item){
[238] Fix | Delete
if (isset($item->status_type) && $item->status_type == 'added_video'){
[239] Fix | Delete
if (isset($item->attachments) && isset($item->attachments->data) && sizeof($item->attachments->data) > 0){
[240] Fix | Delete
$subattachments = $this->getSubattachments($item);
[241] Fix | Delete
if (sizeof($subattachments) > 0){
[242] Fix | Delete
$image= $subattachments[0];
[243] Fix | Delete
$width = $image->width;
[244] Fix | Delete
$height = $image->height;
[245] Fix | Delete
if ($width > 600) {
[246] Fix | Delete
$height = FFFeedUtils::getScaleHeight(600, $width, $height);
[247] Fix | Delete
$width = 600;
[248] Fix | Delete
}
[249] Fix | Delete
$this->image = $this->createImage($image->src, $width, $height);
[250] Fix | Delete
[251] Fix | Delete
if (isset($item->attachments->data[0]->target)){
[252] Fix | Delete
$videoId = $item->attachments->data[0]->target->id;
[253] Fix | Delete
if (isset($item->from->id)){
[254] Fix | Delete
$this->media = $this->createMedia('https://www.facebook.com/plugins/video.php?app_id=&container_width=0&href=https%3A%2F%2Ffacebook.com%2F' . $item->from->id . '%2Fvideos%2F' . $videoId . '%2F&locale=en_US&sdk=joey' /* . '&appId=140463540033583' */, $width, $height, 'video');
[255] Fix | Delete
}
[256] Fix | Delete
else {
[257] Fix | Delete
$this->media = $this->createMedia('http://www.facebook.com/video/embed?video_id=' . $item->object_id, $width, $height, 'video');
[258] Fix | Delete
}
[259] Fix | Delete
}
[260] Fix | Delete
[261] Fix | Delete
$this->carousel = $subattachments;
[262] Fix | Delete
return true;
[263] Fix | Delete
}
[264] Fix | Delete
}
[265] Fix | Delete
}
[266] Fix | Delete
[267] Fix | Delete
if (isset($item->attachments->data) && sizeof($item->attachments->data) > 0){
[268] Fix | Delete
$subattachments = $this->getSubattachments($item);
[269] Fix | Delete
if (sizeof($subattachments) > 0){
[270] Fix | Delete
$image = $subattachments[0];
[271] Fix | Delete
$this->image = $this->createImage($image->src, $image->width, $image->height);
[272] Fix | Delete
$this->media = $this->createMedia($image->src, $image->width, $image->height, 'image', true);
[273] Fix | Delete
$this->carousel = $subattachments;
[274] Fix | Delete
return true;
[275] Fix | Delete
}
[276] Fix | Delete
}
[277] Fix | Delete
[278] Fix | Delete
if (isset($item->source)){
[279] Fix | Delete
$this->image = $this->createImage($item->source);
[280] Fix | Delete
$this->media = $this->createMedia($item->source);
[281] Fix | Delete
return true;
[282] Fix | Delete
}
[283] Fix | Delete
[284] Fix | Delete
if (isset($item->full_picture)){
[285] Fix | Delete
$this->image = $this->createImage($item->full_picture);
[286] Fix | Delete
return true;
[287] Fix | Delete
}
[288] Fix | Delete
[289] Fix | Delete
return false;
[290] Fix | Delete
}
[291] Fix | Delete
[292] Fix | Delete
protected function getCarousel( $item ) {
[293] Fix | Delete
$carousel = parent::getCarousel($item);
[294] Fix | Delete
$subattachments = $this->carousel;
[295] Fix | Delete
[296] Fix | Delete
if (sizeof($subattachments) > 1){
[297] Fix | Delete
foreach ($subattachments as $image){
[298] Fix | Delete
$carousel[] = $this->createMedia($image->src, $image->width, $image->height);
[299] Fix | Delete
}
[300] Fix | Delete
// change 28.08.20
[301] Fix | Delete
// otherwise first pic is duplicated
[302] Fix | Delete
array_shift( $carousel );
[303] Fix | Delete
[304] Fix | Delete
}
[305] Fix | Delete
return $carousel;
[306] Fix | Delete
}
[307] Fix | Delete
[308] Fix | Delete
protected function getImage( $item ) {
[309] Fix | Delete
return $this->image;
[310] Fix | Delete
}
[311] Fix | Delete
[312] Fix | Delete
protected function getMedia( $item ) {
[313] Fix | Delete
return $this->media;
[314] Fix | Delete
}
[315] Fix | Delete
[316] Fix | Delete
protected function getScreenName($item){
[317] Fix | Delete
return $item->from->name;
[318] Fix | Delete
}
[319] Fix | Delete
[320] Fix | Delete
protected function getContent($item){
[321] Fix | Delete
if (isset($item->message)) return self::wrapHashTags(FFFeedUtils::wrapLinks($item->message), $item->id);
[322] Fix | Delete
if (isset($item->story)) return (string)$item->story;
[323] Fix | Delete
return '';
[324] Fix | Delete
}
[325] Fix | Delete
[326] Fix | Delete
protected function getProfileImage( $item ) {
[327] Fix | Delete
$url = "https://graph.facebook.com/" . FFFacebook::API_VERSION . "/{$item->from->id}/picture?width=80&height=80";
[328] Fix | Delete
if (!array_key_exists($url, $this->images)){
[329] Fix | Delete
$this->images[$url] = $this->getLocation($url);
[330] Fix | Delete
}
[331] Fix | Delete
return $this->images[$url];
[332] Fix | Delete
}
[333] Fix | Delete
[334] Fix | Delete
protected function getId( $item ) {
[335] Fix | Delete
return $item->id;
[336] Fix | Delete
}
[337] Fix | Delete
[338] Fix | Delete
protected function getSystemDate( $item ) {
[339] Fix | Delete
return strtotime($item->created_time);
[340] Fix | Delete
}
[341] Fix | Delete
[342] Fix | Delete
protected function getUserlink( $item ) {
[343] Fix | Delete
return 'https://www.facebook.com/'.$item->from->id;
[344] Fix | Delete
}
[345] Fix | Delete
[346] Fix | Delete
protected function getPermalink( $item ) {
[347] Fix | Delete
if (isset($item->link)){
[348] Fix | Delete
return $item->link;
[349] Fix | Delete
}
[350] Fix | Delete
if (isset($item->permalink_url)){
[351] Fix | Delete
return $item->permalink_url;
[352] Fix | Delete
}
[353] Fix | Delete
$parts = explode('_', $item->id);
[354] Fix | Delete
return 'https://www.facebook.com/'.$parts[0].'/posts/'.$parts[1];
[355] Fix | Delete
}
[356] Fix | Delete
[357] Fix | Delete
protected function getAdditionalInfo( $item ) {
[358] Fix | Delete
$additional = parent::getAdditionalInfo( $item );
[359] Fix | Delete
$additional['likes'] = (string)@$item->likes->summary->total_count;
[360] Fix | Delete
$additional['comments'] = isset($item->comments->summary->total_count) ? (string)@$item->comments->summary->total_count : '';
[361] Fix | Delete
$additional['shares'] = isset($item->shares) ? (string)@$item->shares->count : '0';
[362] Fix | Delete
return $additional;
[363] Fix | Delete
}
[364] Fix | Delete
[365] Fix | Delete
/**
[366] Fix | Delete
* @param string $text
[367] Fix | Delete
* @param string $id
[368] Fix | Delete
*
[369] Fix | Delete
* @return mixed
[370] Fix | Delete
*/
[371] Fix | Delete
private function wrapHashTags($text, $id){
[372] Fix | Delete
//return preg_replace('/#([\\d\\w]+)/', '<a href="https://www.facebook.com/hashtag/$1?source=feed_text&story_id='.$id.'">$0</a>', $text);//old
[373] Fix | Delete
/** @noinspection RegExpRedundantEscape */
[374] Fix | Delete
return preg_replace("/#([A-Za-z0-9ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöùúûüýÿ\/\.]*)/u", "<a href=\"https://www.facebook.com/hashtag/$1?source=feed_text&story_id='.$id.'\">#$1</a>", $text);
[375] Fix | Delete
}
[376] Fix | Delete
[377] Fix | Delete
private function getLocation($url, $with_token = true) {
[378] Fix | Delete
if (defined('FF_DONT_USE_GET_HEADERS') && FF_DONT_USE_GET_HEADERS){
[379] Fix | Delete
$location = @$this->getCurlLocation($this->getUrlWithToken( $url ));
[380] Fix | Delete
if (!empty($location) && $location != 0) {
[381] Fix | Delete
return $location;
[382] Fix | Delete
}
[383] Fix | Delete
}
[384] Fix | Delete
else {
[385] Fix | Delete
$headers = $this->getHeadersSafe($with_token ? $this->getUrlWithToken( $url ) : $url , 1);
[386] Fix | Delete
if (isset($headers["Location"])) {
[387] Fix | Delete
return $headers["Location"];
[388] Fix | Delete
} else {
[389] Fix | Delete
$location = @$this->getCurlLocation($with_token ? $this->getUrlWithToken( $url ) : $url);
[390] Fix | Delete
if (!empty($location) && $location != 0) {
[391] Fix | Delete
return $location;
[392] Fix | Delete
}
[393] Fix | Delete
}
[394] Fix | Delete
}
[395] Fix | Delete
[396] Fix | Delete
$location = str_replace('/v2.3/', '/', $url);
[397] Fix | Delete
$location = str_replace('/v2.4/', '/', $location);
[398] Fix | Delete
$location = str_replace('/v2.5/', '/', $location);
[399] Fix | Delete
$location = str_replace('/v2.6/', '/', $location);
[400] Fix | Delete
$location = str_replace('/v2.7/', '/', $location);
[401] Fix | Delete
$location = str_replace('/v2.8/', '/', $location);
[402] Fix | Delete
return $location;
[403] Fix | Delete
}
[404] Fix | Delete
[405] Fix | Delete
private function getCurlLocation($url) {
[406] Fix | Delete
$curl = curl_init();
[407] Fix | Delete
curl_setopt_array( $curl, [
[408] Fix | Delete
CURLOPT_USERAGENT => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36',
[409] Fix | Delete
CURLOPT_HEADER => true,
[410] Fix | Delete
CURLOPT_NOBODY => true,
[411] Fix | Delete
CURLOPT_RETURNTRANSFER => true,
[412] Fix | Delete
CURLOPT_URL => $url
[413] Fix | Delete
]);
[414] Fix | Delete
curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, false);
[415] Fix | Delete
curl_setopt( $curl, CURLOPT_CONNECTTIMEOUT_MS, 5000);
[416] Fix | Delete
curl_setopt( $curl, CURLOPT_TIMEOUT, 60);
[417] Fix | Delete
$headers = explode( "\n", curl_exec( $curl ) );
[418] Fix | Delete
curl_close( $curl );
[419] Fix | Delete
[420] Fix | Delete
$location = '';
[421] Fix | Delete
foreach ( $headers as $header ) {
[422] Fix | Delete
if (strpos($header, "ocation:")) {
[423] Fix | Delete
$location = substr($header, 10);
[424] Fix | Delete
break;
[425] Fix | Delete
}
[426] Fix | Delete
}
[427] Fix | Delete
return $location;
[428] Fix | Delete
}
[429] Fix | Delete
[430] Fix | Delete
private function getHeadersSafe($url, $format){
[431] Fix | Delete
if ( ini_get( 'allow_url_fopen' ) ) {
[432] Fix | Delete
return get_headers( $url, $format );
[433] Fix | Delete
} else {
[434] Fix | Delete
$ch = curl_init( $url );
[435] Fix | Delete
curl_setopt( $ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36');
[436] Fix | Delete
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
[437] Fix | Delete
curl_setopt( $ch, CURLOPT_HEADER, true );
[438] Fix | Delete
curl_setopt( $ch, CURLOPT_NOBODY, true );
[439] Fix | Delete
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
[440] Fix | Delete
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT_MS, 5000);
[441] Fix | Delete
curl_setopt( $ch, CURLOPT_TIMEOUT, 60);
[442] Fix | Delete
$content = curl_exec( $ch );
[443] Fix | Delete
curl_close( $ch );
[444] Fix | Delete
return [$content];
[445] Fix | Delete
}
[446] Fix | Delete
}
[447] Fix | Delete
[448] Fix | Delete
private function getUrlWithToken($url){
[449] Fix | Delete
$this->facebookCache->addRequest();
[450] Fix | Delete
[451] Fix | Delete
$token = $this->accessToken;
[452] Fix | Delete
return $url . "&access_token={$token}";
[453] Fix | Delete
}
[454] Fix | Delete
[455] Fix | Delete
private function getSubattachments($item){
[456] Fix | Delete
$attachments = [];
[457] Fix | Delete
if (isset($item->attachments) && isset($item->attachments->data) && sizeof($item->attachments->data) > 0){
[458] Fix | Delete
$data = $item->attachments->data[0];
[459] Fix | Delete
if (isset($data->media->image)){
[460] Fix | Delete
if (isset($item->status_type) && $item->status_type == 'shared_story'){
[461] Fix | Delete
$attachments[] = $data->media->image;
[462] Fix | Delete
return $attachments;
[463] Fix | Delete
}
[464] Fix | Delete
else $attachments[] = $data->media->image;
[465] Fix | Delete
}
[466] Fix | Delete
if (isset($data->subattachments) && isset($data->subattachments->data)){
[467] Fix | Delete
foreach ($data->subattachments->data as $el){
[468] Fix | Delete
$attachments[] = $el->media->image;
[469] Fix | Delete
}
[470] Fix | Delete
}
[471] Fix | Delete
}
[472] Fix | Delete
return $attachments;
[473] Fix | Delete
}
[474] Fix | Delete
[475] Fix | Delete
/**
[476] Fix | Delete
* TODO: check API in future, 'from' field was deprecated since Feb 2018
[477] Fix | Delete
*
[478] Fix | Delete
* @param $item
[479] Fix | Delete
*
[480] Fix | Delete
* @return stdClass
[481] Fix | Delete
*/
[482] Fix | Delete
private function getComment($item){
[483] Fix | Delete
$obj = new stdClass();
[484] Fix | Delete
$obj->id = $item->id;
[485] Fix | Delete
$obj->from = isset($item->from) ? $item->from : '';
[486] Fix | Delete
$obj->text = $item->message;
[487] Fix | Delete
$obj->created_time = $this->getSystemDate($item);
[488] Fix | Delete
return $obj;
[489] Fix | Delete
}
[490] Fix | Delete
[491] Fix | Delete
private function getPageId(){
[492] Fix | Delete
$accessToken = $this->facebookCache->getAccessToken();
[493] Fix | Delete
if ($this->accessToken === false){
[494] Fix | Delete
$this->errors[] = $this->facebookCache->getError();
[495] Fix | Delete
throw new Exception();
[496] Fix | Delete
}
[497] Fix | Delete
$api = FFFacebook::API_VERSION;
[498] Fix | Delete
$url = "https://graph.facebook.com/{$api}/me/accounts?access_token={$accessToken}";
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function