@@ -81,6 +81,7 @@ const PARAMS__RETURN_URL = 'return_url';
8181const PARAMS__SCOPE = 'scope' ;
8282const PARAMS__SEARCH_TYPE = 'search_type' ;
8383const PARAMS__TEXT = 'text' ;
84+ const PARAMS__USERNAME = 'username' ;
8485
8586// Read variables from environment
8687require ( 'dotenv' ) . config ( ) ;
@@ -118,6 +119,7 @@ const SCOPES = [
118119 'threads_manage_mentions' ,
119120 'threads_delete' ,
120121 'threads_location_tagging' ,
122+ 'threads_profile_discovery' ,
121123] ;
122124
123125app . use ( express . static ( 'public' ) ) ;
@@ -898,6 +900,56 @@ app.get('/oEmbed', async (req, res) => {
898900 } ) ;
899901} ) ;
900902
903+ app . get ( '/profileLookup' , async ( req , res ) => {
904+ const { profile } = req . query ;
905+ if ( ! profile ) {
906+ return res . render ( 'profile_lookup' , {
907+ title : 'Profile Lookup' ,
908+ } ) ;
909+ }
910+
911+ const params = {
912+ [ PARAMS__USERNAME ] : profile ,
913+ }
914+
915+ const profileLookupUrl = buildGraphAPIURL ( `profile_lookup` , params , req . session . access_token ) ;
916+
917+ let response = { } ;
918+ try {
919+ response = await axios . get ( profileLookupUrl , { httpsAgent : agent } ) ;
920+ } catch ( e ) {
921+ console . error ( e ?. response ?. data ?. error ?. message ?? e . message ) ;
922+ }
923+
924+ const username = response . data ?. username ;
925+ const displayName = response . data ?. name ;
926+ const profilePictureUrl = response . data ?. profile_picture_url ;
927+ const isVerified = response . data ?. is_verified ;
928+ const bio = response . data ?. biography ;
929+ const formatCount = count => count ? count . toLocaleString ( 'en-US' ) : undefined ;
930+ const followerCount = formatCount ( response . data ?. follower_count ) ;
931+ const likesCount = formatCount ( response . data ?. likes_count ) ;
932+ const quotesCount = formatCount ( response . data ?. quotes_count ) ;
933+ const repliesCount = formatCount ( response . data ?. replies_count ) ;
934+ const repostsCount = formatCount ( response . data ?. reposts_count ) ;
935+ const viewsCount = formatCount ( response . data ?. views_count ) ;
936+
937+ return res . render ( 'profile_lookup' , {
938+ title : 'Profile Lookup for @' . concat ( profile ) ,
939+ username,
940+ displayName,
941+ profilePictureUrl,
942+ isVerified,
943+ bio,
944+ followerCount,
945+ likesCount,
946+ quotesCount,
947+ repliesCount,
948+ repostsCount,
949+ viewsCount,
950+ } ) ;
951+ } ) ;
952+
901953https
902954 . createServer ( {
903955 key : fs . readFileSync ( path . join ( __dirname , '../' + HOST + '-key.pem' ) ) ,
0 commit comments