Geliştiriciler olarak sanal alemin en büyük platformlarından bazılarının geliştirmelerimizde kullandığımız olmazsa olmaz api’ler için derlemiş olduğum ve banada ileride kaynak olması açısından bu makaleyi yazmayı uygun gördüm ve güncel olarak geliştirmelerimde kullandığım tüm platformları eklemeyi düşünüyorum.
Bazı platformların api’leri ile ilgili bilmeniz gerekenler
Tüm apiler için ortak bir yapı kullanmak isterseniz o zaman rapidapi.com yada market.mashape.com adresine bir gözatmanızı öneririm.
İşlem | Adres |
---|---|
Dökümantasyon | https://developers.google.com/ |
Playground Ortamı | https://developers.google.com/oauthplayground/ |
Developer Ortamı | https://console.developers.google.com/apis/dashboard |
Token Alma
Token almak için alttaki POST adresini kullanabilirsiniz.
1 2 3 4 5 6 | POST https://accounts.google.com/o/oauth2/token Form data: code=... &client_id=... &secret_key=... &redirect_uri=... &grant_type=authorization_code |
Token Durumu Sorgulama
Aldığınız token’ın durumunu sorgulamak için kullanmanız gereken adres şu şekilde.
1 | https://www.googleapis.com/oauth2/v1/tokeninfo?access_token={access_token} |
Flickr
İşlem | Adres |
---|---|
Dökümantasyon | https://www.flickr.com/services/api/ |
Playground ortamı | https://developers.google.com/oauthplayground/ |
Sendloop
https://sendloop.com/help/api/getting-started/
İşlem | Adres |
---|---|
Dökümantasyon | https://sendloop.com/help/api/getting-started/ |
Playground Ortamı | https://help.sendloop.com/v1.0/reference (Şuan sadece 1 versiyon api playgroun’u mevcuttur ama son sürüm 3’dür.) |
Developer Ortamı | https://sendloop.com/login |
İşlem | Adres |
---|---|
Dökümantasyon | https://dev.twitter.com/docs |
Playground Ortamı | https://dev.twitter.com/rest/tools/console |
Developer Ortamı | https://dev.twitter.com |
Kütüphaneler
Platfrom | Adres |
---|---|
.NET | https://github.com/linvi/tweetinvi |
Masaüstü uygulaması windows servis uygulamasından access token almak
Bütün geliştirdiğimiz projeler maalesef web projeleri olamayabiliyor bazen masaüstü, windows servis gibi uygulamalarda yazabiliyoruz bu durumda facebook’dan access token almak için yapmanız gereken alttaki gibi bir kod bloğu kullanıp sizin barındıracağınız herhangi bir redirect_uri’ye ihtiyaç olmadan bu ihtiyacı giderebilirsiniz.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | client = new FacebookClient(); try { dynamic getOuth = client.Get("oauth/access_token", new { client_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx", client_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", grant_type = "client_credentials", redirect_uri="https://www.facebook.com/connect/login_success.html" }); token = getOuth.access_token.ToString(); } |
FacebookClient sınıfını nereden bulucam gibi bir soru içinde cevabı https://github.com/facebook-csharp-sdk/facebook-csharp-sdk adresinden bulabilirsiniz.
“xxx…” ile işaretlenmiş kısımlara kendi facebook uygulamanızın bilgilerini girerseniz access token’ı kolayca elde edebilirsiniz.
Varolan app access token ve user acess token değerleri access token’ın geçerli olup olmadığını kontrol etmek için alttaki adresi kullanabilirsiniz. https://graph.facebook.com/debug_token?input_token=INPUT_TOKEN&access_token=ACCESS_TOKEN
- input_token: the Access Token to debug access_token: your App Access Token or a valid User Access Token from a developer of the app.
Bir sayfanın like ve paylaşım sayılarını uygulama oluşturmadan direkt link ile alma
1 | https://graph.facebook.com/?fields=og_object%7Blikes.summary(total_count).limit(0)%7D,share&id=http://www.muratoner.net&summary=true |
Reactions’ları alan kod.
Reaction türleri; ‘love,’ ‘haha,’ ‘wow,’ ‘sad,’ and ‘angry.’
1 | 212516295342_10159864917960343?fields=message,reactions.summary(true),from,created_time,updated_time ,reactions.type(LOVE).limit(0).summary(total_count).as(reactions_love) ,reactions.type(WOW).limit(0).summary(total_count).as(reactions_wow), reactions.type(LIKE).limit(0).summary(total_count).as(reactions_like),reactions.type(ANGRY).limit(0).summary(total_count).as(reactions_angry), reactions.type(HAHA).limit(0).summary(total_count).as(reactions_haha),reactions.type(SAD).limit(0).summary(total_count).as(reactions_sad) &limit=1 |
Bir sayfadaki post’un toplam eriştiği kişi sayısını alma
1 2 | curl -i -X GET \ "https://graph.facebook.com/v2.9/266807830094914_1225181000924254/insights/post_impressions?access_token=@access_token" |
Facebook isteklerini tek request’de yapabilmek
1 2 3 4 | curl \ -F 'access_token=...' \ -F 'batch=[{"method":"GET", "relative_url":"me"},{"method":"GET", "relative_url":"me/friends?limit=50"}]' \ https://graph.facebook.com |
Detaylı Bilgi: https://developers.facebook.com/docs/graph-api/making-multiple-requests
OAUTH İçin Ortak Bazı Bilgiler
Refresh Token Nedir?
Refresh Token authorization server tarafından mevcutta olan Access Token’ın expire süresi sona ermeye yaklaştığında veya sona erdiğinde, yeni bir Access Token elde edebilmek için client’a verilir. Refresh Token’ın kullanımı opsiyonel olup, authorization server tarafından Access Token alınacağı zaman, Refresh Token da beraberinde verilir.
Not: Access token‘ı Resource Server ile haberleşme için kullanıyoruz ama Refresh token‘ı token yenilemek için Authorization Server ile haberleşmede kullanıyoruz. Refresh token ile buraya kadar anlattıklarımızın tümünü alttaki görselde görebilirsiniz.