paint-brush
Ukudiliza uhlelo lokusebenza lwe-iOS ye-Reddit - Imininingwane Ngama-API, Ukusebenza, Ukuphepha, kanye Nokuhlolwa kwe-A/Bnge@abhisheksachan
346 ukufundwa
346 ukufundwa

Ukudiliza uhlelo lokusebenza lwe-iOS ye-Reddit - Imininingwane Ngama-API, Ukusebenza, Ukuphepha, kanye Nokuhlolwa kwe-A/B

nge Abhishek Sachan7m2024/11/26
Read on Terminal Reader

Kude kakhulu; Uzofunda

Ilukuluku lami lingiholela ekuhlaziyeni okungemuva kokusebenza kohlelo lokusebenza lwe-Reddit iOS futhi ngiveze imininingwane ethile emihle mayelana nama-Reddit API.
featured image - Ukudiliza uhlelo lokusebenza lwe-iOS ye-Reddit - Imininingwane Ngama-API, Ukusebenza, Ukuphepha, kanye Nokuhlolwa kwe-A/B
Abhishek Sachan HackerNoon profile picture
0-item

Ngithole ulwazi lohlelo lokusebenza lwe-Reddit lwe-iOS lungcono kunenguqulo yewebhu, ngakho-ke ngicabange ukubheka ukuthi ilayisha kanjani idatha ngokushesha okungaka. Nakhu ukuchithwa kohlelo lokusebenza lwe-Reddit's iOS.


Nakhu okugqamile:

  • Isebenzisa ukufakazela ubuqiniso okusekelwe kuToken.
  • Isebenzisa ama-GraphQL API cishe kuyo yonke into kusukela ekucushweni nasekuhlolweni kuya ekuthumeleni ulwazi.
  • Iqapha ukusebenza kwesistimu yayo ye-API njengoba itholwa abasebenzisi bayo besebenzisa i-API ebizwa ngokuthi i-w3-reporting.
  • Eziningi ze-GraphQL API ibiza kuphela igama lokusebenza elidluliswayo ngaphandle kokuguquguquka, ngicabanga ukuthi basebenzisa i-middleware ukuze bakhiphe ukucushwa kokuguquguqukayo kusukela ekupheleni. Isevisi engemuva igcwalisa ulwazi olususelwe egameni lomsebenzi.
  • I-Reddit isebenzisa i-Web Socket yesici samazwana abukhoma.


Nakhu ukuchithwa okuningiliziwe kwamakholi we-API. Ngisebenzise Uhlelo Lokusebenza Lwedeskithophu Yesicelo ukuze ngibambe uhlelo lokusebenza lwe-iOS ye-Reddit, imiyalelo yokusetha inikezwa lapha .

Ubuchwepheshe obusetshenziswa

I-Reddit App idalwe nayo

  • Uhlelo lokusebenza lwe-iOS lweReddit lusebenzisa ama-GraphQL APIs ukulayisha konke okuqukethwe.
  • Ukuqinisekisa okusekelwe kumathokheni kusetshenziselwa ukuqinisekisa abasebenzisi.
  • Ukuqapha Ukusebenza ngokubika ukusebenza kwe-API ekugcineni komsebenzisi.
  • Ukubeka amazwana bukhoma kusekelwa kusetshenziswa i-WebSocket.
  • Ukucushwa Kwe-Dynamic ukuze ulawule ukude ukuziphatha kohlelo lokusebenza ngaphandle kokukhipha izinguqulo ezintsha.
  • I-Dynamic Experiments yokulawula ukude ukuhlola, okungadingi ukusetshenziswa okusha ukuze kuguqulwe isimo sokuhlolwa.

I-UX engcono ngokulayisha kuqala

Umbuzo omkhulu enganginawo ukuthi uhlelo lokusebenza lusebenza kanjani ngokushesha okungaka uphendulwe lapho kuhlolwa impendulo ye -FeedPostDetailsByIds API. Le API ibizwa esikrinini sasekhaya ngama-id wokuthunyelwe abonisiwe futhi iza nolwazi oluningiliziwe oluboniswa ngemva kokuchofoza okuthunyelwe. Lokhu kulayishwa kuqala kokuthunyelwe okuphezulu kusize ekuboniseni ngokushesha isikrini semininingwane yokuthunyelwe ngaphandle kwanoma yisiphi isilayishi.


  • Okuthunyelwe okulayishwa ngaphambilini kuboniswa ekuphakeleni.
  • Isikhathi sokuphendula sama-API naso siyashesha kakhulu.

Ukuphepha kwe-GraphQL APIs

Imibuzo ye-GraphQL iqukethe idatha nesakhiwo sempendulo edingekayo. Igama lomsebenzi ngokuvamile uyazikhethela. Ama-API amaningi e-Reddit anamagama okusebenza kuphela emibuzweni futhi okuguquguqukayo kutholakala kuphela uma kukhona okuguquguqukayo okukusikrini/izihlungi ezifana nokuphakelayo okunezinketho zokuthunyelwe ezishisayo nezakamuva.


Lokhu kunikeza ukulawula okuncane kubathuthukisi abaphambili ukwenza izinguquko ngokuzimele kodwa ukulawula okwengeziwe ekusebenziseni kabi ama-API ukuze balande idatha engadingekile ngemva kwayo yonke i-API ebheke kumsebenzisi.

Imilingo elawulwa kude

Ukwenza izivivinyo kuzinhlelo zokusebenza zomdabu ze-iOS kunzima kudinga ukuphinda kusetshenziswe ukuze kunikwe amandla noma ukukhubaza ukuhlola, kodwa i-Reddit isethe uhlelo lokusebenza ngendlela yokuthi izivivinyo zingalawulwa ukude. Zonke izivivinyo zilayishwa ku-API kanye namanani azo kanye nezimo. Uhlelo lokusebenza luvula ngokuzenzakalelayo ukwahluka kokuhlolwa elikunikezile.

Ukulawula Izici ezisuselwe kufulegi

Ngabasebenzisi abaningi kangaka, ukuhlolwa nezici kungcono ukuzilawula ukude. I-Reddit yenza umsebenzi omuhle kakhulu wokulawula lezi zici ukude.

Ikholi ye-GetAllDynamicConfigs API njengoba kukhonjisiwe kokuthi Cela


Njalo lapho kwethulwa uhlelo lokusebenza, izobiza i-API yokumisa ukuze ilayishe okuguquguqukayo kokucushwa okungu-400+. Ngokusekelwe kulokhu okuguquguqukayo ibonisa izici ezihlukene nokuhlukahluka kwezici.

Ilungisa impendulo ye-API

Imfihlo yeKarmas

I-API enegama lokusebenza GetTopKarmaSubreddits ithola uhlu lwama-subreddits aphezulu anamaphuzu e-karma atholwe kokukodwa. Le API iveza ukuthi mangaki amazwana kanye ne-karma yokuthunyelwe esikuzuzile emsebenzini wethu ku-sub-reddit ngayinye. Angikwazanga ukuthola lolu lwazi ngaphakathi kwewebhu ye-Reddit kanye ne-UI yeselula.


I-Karma ye-Subreddit ngayinye

Ububanzi Bokuthuthuka

Ngenkathi ngifunda ama-API ukuze ngithole ukuthi iletha luphi uhlobo lwedatha, ngithole SubredditFeedElements API ilayisha okuphakelayo kwe-sub-reddit ekhethiwe kodwa ngokuthunyelwe ngakunye, ine-JSON ehlanganisiwe yolwazi oluncane lwe-reddit. Lolu lwazi alunalutho futhi lungasuswa ukuze kwehliswe umthwalo wenethiwekhi we-API futhi kuthuthukiswe ukusebenza kwayo.


Qaphela: I SubredditFeedElements API manje isithathelwe indawo yi SubredditFeedSdui API futhi inkinga isilungisiwe.

Sebenzisa i-AI ukuthola imininingwane

Ngizamile ukusebenzisa i-ChatGPT ukuze ngithole imininingwane ethile kuma-API. Ngakho-ke dala ifayela elinawo wonke ama-API ane-curl yawo kanye nezimpendulo zawo kuwo. Kulayishwe leli fayela ku-CustomGPT ukuze ngikwazi ukubeka noma yiluphi uhlobo lombuzo. Inikeze imininingwane ethile ebibonakala njengokuthi hlobo luni lokusetshenziswa i-API engase ibe nalo kanye nesakhiwo sempendulo kodwa yahlohla kakhulu, cishe ngenxa yama-API amaningi noma angiyena uchwepheshe wokwazisa. Eminye yemibono enikezwe i-AI:


  1. I GetAllExperimentVariants API — Ukuhlola okuningi kunamagama athile "okuhlukile", okuhlanganisa izinketho ezifana enabled , variant_1 , control_model , kanye ne one_feed_ph_bridge_new_users . Lesi sigaba siphakamisa ukuthi i-Reddit ihlola izici kumasegimenti athile wabasebenzisi ukuze kutholwe umthelela wazo. Isibonelo, isilingo esithi d2x_avatar_in_comments_loggedin sinokuhlukahluka okubili, loggedin , nokuphuma loggedout , okungase kuhlole isici ngokusekelwe esimweni sokuqinisekisa somsebenzisi.
  2. I GetAllExperimentVariants API — Ukuhlola kuhlanganisa hybrid_video_rollout_android_v2 , active_sales , kanye ne gql_google_maps_integration , ekhomba inhlobonhlobo yokuhlolwa kwezici ezihlanganisa ukusebenza kwevidiyo, ukubekwa kwezikhangiso, ukuthuthukiswa kokusetshenziswa kubonwa, kanye nokuhlanganisa okuvela eceleni.
  3. I GetAccountDetails API — Impendulo ye-API iqukethe izinkambu ezihlukahlukene ezichaza isimo se-akhawunti yomsebenzisi, njenge isSubredditCreationAllowed , isNameEditable , isPasswordSet , kanye nesimo somongameli somsebenzisi. Ukwengeza, kuhlanganisa suspensionExpiresAt kanye isSuspended , okubonisa ukuthi i-akhawunti okwamanje imisiwe noma ivinjelwe.

Uhlu lwama-API

Kukhona uhlu lwama-GraphQL APIs engiwafunde ukuze ngiqonde ukuthi iReddit isebenza kanjani. Bekukhona amanye ama-API anjengokufakazela ubuqiniso, ukubika njll. Angizange ngiwafake kulolu hlu.

Isikrini

I-GraphQL API
(igama lokusebenza)

Incazelo

Ikhaya

GetAllDynamicConfigs

Ilayisha amapharamitha angu-400+ asekelwe ekutheni yiziphi izici zohlelo lokusebenza ezisebenzayo. Ukulungiselelwa kukufomethi yenani lokhiye elivamile kanye nohlobo lwenani okungaba i-JSON, i-float, iyunithi yezinhlamvu njll.


GetAllExperimentVarians

Isicelo siqukethe ulwazi olumayelana nohlelo lokusebenza nedivayisi ezonikezwa ukuhlolwa okuhloselwe idivayisi nenguqulo yohlelo lokusebenza. Impendulo iqukethe uhlu lwazo zonke izivivinyo ezine-id, i-experimentName, inguqulo nesimo.


GetAccount

Ilayisha yonke imininingwane yomsebenzisi ongene ngemvume.


IkhayaFeedSdui

Ilayisha amaposi ambalwa okuqala anemininingwane encane engaboniswa ekhasini eliyisiqalo.


I-FeedPostDetailsByIds

Ilayisha kuqala okuthunyelwe kusetshenziswa ama-id anayo yonke imininingwane, uma kwenzeka umsebenzisi achofoza okuthunyelwe.


I-DiscoverBarRecommendations

Zitholele idatha yebha.


UserPremiumSubscription

Idatha ehlobene nokubhaliselwe kwe-premium yomsebenzisi


I-GetUserAdEligibility

Ithola ukufaneleka kwesikhangiso somsebenzisi nanoma yiziphi izintandokazi.


Ama-BadgeCounts

Ulwazi mayelana namabheji atholwe umsebenzisi.




Ikhasi le-Subreddit

SubredditChannels

Ilayisha yonke imininingwane eyisisekelo mayelana nomphakathi njengencazelo, izithonjana, izinto zokubala, izinhlobo zokuthunyelwe ezivunyelwe, nemibala.


SubredditTaxonomyTopics

Ilayisha isigaba somphakathi kanye nombhalo obonisiwe njengokuthi uma ngilayisha umphakathi r/software uzobonisa #20 ku-Software & Apps.


IsInvitePending

Njengoba igama liphakamisa hlola isimemo esilindile, kodwa ungaqiniseki ukuthi yisiphi isimemo.


SubredditChannels

Ilayisha iziteshi zengxoxo ze-sub-reddit, ngibheke ama-subreddits amaningi kodwa angiwatholanga.


I-blockedRedditors

Iletha idatha uma umsebenzisi evinjiwe.


Thola amaModerators

Ithola uhlu lwamamodeli.


I-FetchStructuredStyleAndWidgets

Le API iletha ulwazi mayelana nesitayela, imithetho kanye nemininingwane yomphakathi.


Izincomo Zomphakathi Ezihlobene

Le API iletha imiphakathi ehlobene.


I-SubredditMuting

Ihlola ukuthi i-subreddit ithulisiwe yini.


I-SubredditFeedElements

Ilayisha okuphakelayo kwe-sub-reddit. Kudingeka izihlungi nezinketho zesakhiwo ezikhethelwe i-sub-reddit. Iletha yonke imininingwane mayelana nokuthunyelwe okumele kuboniswe kokuphakelayo.


I-PostInfoByIdComments

Lesi sicelo silayisha kuqala amazwana wokuthunyelwe kokuqala kuphela.




Thumela Ikhasi

I-GetCustomEmojisStatus

Le API ibizwe nge-id ye-sub-reddit futhi ilayisha isimo sama-emoji angokwezifiso ku-sub-reddit. Akucaci kahle ukuthi kungani le API ibizwa, kodwa ngiyibonile izikhathi eziningi. Impendulo isEnabled: false kuzo zonke izimo ehloliwe.


I-GetSubredditAchievementFlairsStatus

Ngokufanayo nesimo se-emoji kuthatha i-sub-reddit id futhi ithola impendulo njengeVunyiwe: amanga . Inhloso yalokhu ayikangicaceli.


I-PostInfoByIdComments

Le API isetshenziselwa ukulayisha amazwana wokuthunyelwe ngokusebenzisa i-id yokuthunyelwe ephasiswe esicelweni.


AmazwanaPageAds

Ilayisha isikhangiso ngenhla nje kwamazwana.




Ikhasi Lephrofayela

I-RedditorByName

Ilayisha imininingwane yephrofayili yomsebenzisi ongene ngemvume.


I-PostSetSettings

Inombolo yokuthunyelwe okuzolayishwa.


I-GetTopKarmaSubreddits

Thola uhlu lwama-subreddits aphezulu anamaphuzu e-karma emphakathini ngamunye, le API iveza ukuthi mangaki amazwana kanye ne-karma yokuthumela esikuzuzile emsebenzini wethu ku-sub-reddit ngayinye.


UserProfileFeed

Isiphakeli sephrofayela yomsebenzisi esiqukethe amazwana nokuthunyelwe.


UserPublicTrophies

Uhlu lwezimpumelelo nezindondo ezizuzwe ngegama lomsebenzisi elidluliselwe esicelweni nge-id, igama nesithombe okufanele siboniswe.


I-TippingProfileMigrated

Imininingwane mayelana nephrofayili yokunikeza izeluleko, awukasebenzisi lesi sici kakhulu. Kubonise ibhalansi engu-0 kuphrofayela yami 😄.

Isiphetho

Ngingathanda ukwenza amaphuzu ambalwa ekuphetheni kwalesi sivivinyo sokudiliza.

  • Ama-API e-Reddit awasheshi kakhulu kunalokho asebenzisa ukulayisha kuqala ukuze anikeze ulwazi olungcono lomsebenzisi.
  • Umsebenzi wama-API awupheli, ngisho nonjiniyela weReddit unomsebenzi othile okufanele awenze ukuze awuthuthukise.
  • Ukugcina ukulungiselelwa kohlelo lokusebenza nokuhlola ukude kunganikeza ukulawula okuhle phezu kokuhlangenwe nakho komsebenzisi.
  • Onjiniyela baka-Ocery benze umsebenzi omuhle kakhulu ekuboniseni igama lokusebenza nge-GraphQL Isicelo ngasinye, okwenza impilo yama-devs ibe lula kakhulu.