This repository has been archived by the owner on Feb 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fbphotos_base.php
74 lines (64 loc) · 2.58 KB
/
fbphotos_base.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/** -----------------------------------------------
* Fbphotos Base
* -----------------------------------------------
* The base file that provides the core vars and
* functions for the other files that inherit from
* it.
*
* @package Fbphotos
* @author Greg Whitworth
*/
class Fbphotos_base {
protected $facebook_id;
protected $fb_graph_uri;
protected $fb_settings_table;
protected $valid_fb_id;
protected $data;
public function __construct()
{
$this->EE =& get_instance();
$this->fb_graph_uri = 'http://graph.facebook.com';
$this->fb_settings_table = 'fb_photo_settings';
$this->facebook_id = $this->get_setting_value( 'facebook_id' );
$this->get_facebook_graph_data( $this->facebook_id, '' );
}
/** =================================================
// Get Setting Value
// -------------------------------------------------
// Will return the selected setting from the
// exp_fb_photo_settings table.
// -------------------------------------------------
// @return str
// ================================================= */
public function get_setting_value( $setting_name )
{
$query = $this->EE->db->get_where( $this->fb_settings_table, array('setting_name' => $setting_name ) );
$results = $query->row( $this->fb_settings_table );
return $results->setting_value;
}
/** =================================================
// Get Facebook Graph Data
// -------------------------------------------------
// Does a facebook graph call and returns the object
// -------------------------------------------------
// @return object
// @param string : api_ext
// ================================================= */
public function get_facebook_graph_data( $id, $api_ext )
{
$graph_uri = sprintf( '%s/%s/%s', $this->fb_graph_uri, $id, $api_ext );
$result = @file_get_contents( $graph_uri );
if( $api_ext == 'albums' && ( !$result || $result == "" ) ) {
return $this->data['message'] = 'Your Facebook account is set to private, we can not pull albums from your account.';
}
elseif( !$result ) // If the facebook ID is bad
{
$this->valid_fb_id = false;
return $this->data['message'] = 'Not a valid Facebook ID';
}
$this->valid_fb_id = true;
return json_decode( $result );
}
}
?>