Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
Facebook_Helpers::transient_get_user_connected( $user_id, $token )
Retrieve the connected user from the transient.
Contents
Parameters Parameters
- $user_id
-
(Required)
- $token
-
(Required)
Return Return
(array|mixed)
Source Source
File: src/integrations/facebook/helpers/facebook-helpers.php
private function transient_get_user_connected( $user_id, $token ) { $response = array( 'user_id' => 0, 'name' => '', 'picture' => '', ); $transient_key = 'uo-fb-transient-user-connected'; $transient_user_connected = get_transient( $transient_key ); if ( false !== $transient_user_connected ) { return $transient_user_connected; } $request = wp_remote_get( 'https://graph.facebook.com/v11.0/' . $user_id, array( 'body' => array( 'access_token' => $token, 'fields' => 'id,name,picture', ), ) ); $graph_response = wp_remote_retrieve_body( $request ); if ( ! is_wp_error( $graph_response ) ) { $graph_response = json_decode( $graph_response ); $response['user_id'] = $graph_response->id ?? ''; $response['name'] = $graph_response->name ?? ''; $response['picture'] = $graph_response->picture->data->url ?? ''; set_transient( $transient_key, $response, DAY_IN_SECONDS ); } return $response; }
Expand full source code Collapse full source code View on Github