MCPcopy Create free account
hub / github.com/Preloading/TwitterAPIBridge / GetUserInfo

Function GetUserInfo

bluesky/blueskyapi.go:444–476  ·  view source on GitHub ↗
(pds string, token string, screen_name string, nocache bool)

Source from the content-addressed store, hash-verified

442}
443
444func GetUserInfo(pds string, token string, screen_name string, nocache bool) (*bridge.TwitterUser, error) {
445 if !nocache {
446 if user, found := userCache.Get(screen_name); found {
447 return &user, nil
448 }
449 }
450
451 url := pds + "/xrpc/app.bsky.actor.getProfile" + "?actor=" + screen_name
452
453 resp, err := SendRequest(&token, http.MethodGet, url, nil)
454 if err != nil {
455 return nil, err
456 }
457 defer resp.Body.Close()
458 if resp.StatusCode != http.StatusOK {
459 bodyBytes, _ := io.ReadAll(resp.Body)
460 bodyString := string(bodyBytes)
461 fmt.Println("Response Status:", resp.StatusCode)
462 fmt.Println("Response Body:", bodyString)
463 return nil, errors.New(bodyString) // return response
464 }
465
466 author := User{}
467 if err := json.NewDecoder(resp.Body).Decode(&author); err != nil {
468 return nil, err
469 }
470
471 twitterUser := AuthorTTB(author)
472
473 userCache.SetMultiple([]string{author.DID, author.Handle}, *twitterUser)
474
475 return twitterUser, nil
476}
477
478func GetUserInfoRaw(pds string, token string, screen_name string) (*User, error) {
479 url := pds + "/xrpc/app.bsky.actor.getProfile" + "?actor=" + screen_name

Callers

nothing calls this directly

Calls 4

SendRequestFunction · 0.85
AuthorTTBFunction · 0.85
SetMultipleMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected