1 | <?php |
||
38 | abstract class FacebookSignedRequestFromInputHelper |
||
39 | { |
||
40 | /** |
||
41 | * @var SignedRequest|null The SignedRequest entity. |
||
42 | */ |
||
43 | protected $signedRequest; |
||
44 | |||
45 | /** |
||
46 | * @var FacebookApp The FacebookApp entity. |
||
47 | */ |
||
48 | protected $app; |
||
49 | |||
50 | /** |
||
51 | * @var OAuth2Client The OAuth 2.0 client service. |
||
52 | */ |
||
53 | protected $oAuth2Client; |
||
54 | |||
55 | /** |
||
56 | * Initialize the helper and process available signed request data. |
||
57 | * |
||
58 | * @param FacebookApp $app The FacebookApp entity. |
||
59 | * @param FacebookClient $client The client to make HTTP requests. |
||
60 | * @param string|null $graphVersion The version of Graph to use. |
||
61 | */ |
||
62 | public function __construct(FacebookApp $app, FacebookClient $client, $graphVersion = null) |
||
70 | |||
71 | /** |
||
72 | * Instantiates a new SignedRequest entity. |
||
73 | * |
||
74 | * @param string|null |
||
75 | */ |
||
76 | public function instantiateSignedRequest($rawSignedRequest = null) |
||
86 | |||
87 | /** |
||
88 | * Returns an AccessToken entity from the signed request. |
||
89 | * |
||
90 | * @return AccessToken|null |
||
91 | * |
||
92 | * @throws \Facebook\Exceptions\FacebookSDKException |
||
93 | */ |
||
94 | public function getAccessToken() |
||
111 | |||
112 | /** |
||
113 | * Returns the SignedRequest entity. |
||
114 | * |
||
115 | * @return SignedRequest|null |
||
116 | */ |
||
117 | public function getSignedRequest() |
||
121 | |||
122 | /** |
||
123 | * Returns the user_id if available. |
||
124 | * |
||
125 | * @return string|null |
||
126 | */ |
||
127 | public function getUserId() |
||
131 | |||
132 | /** |
||
133 | * Get raw signed request from input. |
||
134 | * |
||
135 | * @return string|null |
||
136 | */ |
||
137 | abstract public function getRawSignedRequest(); |
||
138 | |||
139 | /** |
||
140 | * Get raw signed request from POST input. |
||
141 | * |
||
142 | * @return string|null |
||
143 | */ |
||
144 | public function getRawSignedRequestFromPost() |
||
152 | |||
153 | /** |
||
154 | * Get raw signed request from cookie set from the Javascript SDK. |
||
155 | * |
||
156 | * @return string|null |
||
157 | */ |
||
158 | public function getRawSignedRequestFromCookie() |
||
166 | } |
||
167 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: