test

Bu işlem için moz api olarak bilinen bir api sağlayıcı ile çalışılabilir. Belirli sorguya kadar ücretsiz fakat belirli sorgudan sonra ücretli bir api servisidir.

//Moz api response'u

<?php

add_filter( 'sanitize_file_name', 'mb_strtolower' );

public Result GetPaDaInfo(string url)
{

string apiKey = "", apiSecret = ""; //moz apiden alınan api key ve secret buraya eklenir.

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://lsapi.seomoz.com/v2/url_metrics");  //istek attığımız endpoint burda belirtilmiştir. Post isteği atmaktayız.
request.Headers.Add("Authorization", $"Basic {Base64Encode(apiKey, apiSecret)}"); //Basic Auth yöntemi ile oturum açmaktadır. Header bu bilgileri ekledik.
request.Headers.Add("Cookie", "__cf_bm=zMd6CIhaTVjn1XfilEX2LTi0Rvt2Q1L1LSqWryg.Ngo-1692121828-0-AaToFl1el/60kH9yCAq4AIZjvJCFw3wjB4+1CldEa2xAL0PQrAdddWDvuzeYXBxsjkAPLYic29jcSpsCYUzUxBk=");
var content = new StringContent("{\r\n \"targets\": [\"" + url + "\"]\r\n}", null, "application/json");
request.Content = content;
var response = client.SendAsync(request).GetAwaiter().GetResult();
response.EnsureSuccessStatusCode();
var result = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();

return JsonConvert.DeserializeObject<MozApiResponse>(result).results[0];

}

public static string Base64Encode(string apikey, string apisecret)
{
string auth = apikey + ":" + apisecret;
var authBytes = Encoding.UTF8.GetBytes(auth);
return Convert.ToBase64String(authBytes);
}

public class MozApiResponse
{
public Result[] results { get; set; }
}

public class Result
{
public string page { get; set; }
public string subdomain { get; set; }
public string root_domain { get; set; }
public string title { get; set; }
public string last_crawled { get; set; }
public double? http_code { get; set; }
public double? pages_to_page { get; set; }
public double? nofollow_pages_to_page { get; set; }
public double? redirect_pages_to_page { get; set; }
public double? external_pages_to_page { get; set; }
public double? external_nofollow_pages_to_page { get; set; }
public double? external_redirect_pages_to_page { get; set; }
public double? deleted_pages_to_page { get; set; }
public double? root_domains_to_page { get; set; }
public double? indirect_root_domains_to_page { get; set; }
public double? deleted_root_domains_to_page { get; set; }
public double? nofollow_root_domains_to_page { get; set; }
public double? pages_to_subdomain { get; set; }
public double? nofollow_pages_to_subdomain { get; set; }
public double? redirect_pages_to_subdomain { get; set; }
public double? external_pages_to_subdomain { get; set; }
public double? external_nofollow_pages_to_subdomain { get; set; }
public double? external_redirect_pages_to_subdomain { get; set; }
public double? deleted_pages_to_subdomain { get; set; }
public double? root_domains_to_subdomain { get; set; }
public double? deleted_root_domains_to_subdomain { get; set; }
public double? nofollow_root_domains_to_subdomain { get; set; }
public double? pages_to_root_domain { get; set; }
public double? nofollow_pages_to_root_domain { get; set; }
public double? redirect_pages_to_root_domain { get; set; }
public double? external_pages_to_root_domain { get; set; }
public double? external_indirect_pages_to_root_domain { get; set; }
public double? external_nofollow_pages_to_root_domain { get; set; }
public double? external_redirect_pages_to_root_domain { get; set; }
public double? deleted_pages_to_root_domain { get; set; }
public double? root_domains_to_root_domain { get; set; }
public double? indirect_root_domains_to_root_domain { get; set; }
public double? deleted_root_domains_to_root_domain { get; set; }
public double? nofollow_root_domains_to_root_domain { get; set; }
public double? page_authority { get; set; }
public double? domain_authority { get; set; }
public float link_propensity { get; set; }
public double? spam_score { get; set; }
public double? root_domains_from_page { get; set; }
public double? nofollow_root_domains_from_page { get; set; }
public double? pages_from_page { get; set; }
public double? nofollow_pages_from_page { get; set; }
public double? root_domains_from_root_domain { get; set; }
public double? nofollow_root_domains_from_root_domain { get; set; }
public double? pages_from_root_domain { get; set; }
public double? nofollow_pages_from_root_domain { get; set; }
public double? pages_crawled_from_root_domain { get; set; }
}

<?php

add_filter( 'sanitize_file_name', 'mb_strtolower' );
 

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

Bu site, istenmeyenleri azaltmak için Akismet kullanıyor. Yorum verilerinizin nasıl işlendiği hakkında daha fazla bilgi edinin.