The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.
Yardım edebilir misiniz? Normalde access_token anahtarında bir veri almam lazım.
C# Kodu
static async Task<string> TokenOlustur()
{
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("http://url.com/");
client.DefaultRequestHeaders.Add("Accept", "application/json");
client.DefaultRequestHeaders.Add("cache-control", "no-cache");
var content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("grant_type", "password"),
new KeyValuePair<string, string>("username", "admin"),
new KeyValuePair<string, string>("password", "12345"),
});
var result = await client.PostAsync("token", content);
string resultContent = await result.Content.ReadAsStringAsync();
var obj = JObject.Parse(resultContent);
if (Token == "")
{
Token = (string)obj["access_token"];
}
return Token;
}Benim yazdığım php kodufunction m_curl($url = null, $post = false) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('cache-control: no-cache', 'Accept: application/json'));
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; tr-TR; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
$rt = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
return $rt;
}
$veri_dizi = [
'grant_type' => "password",
'username' => "admin",
'password' => "12345"
];
$http_build_query = http_build_query($veri_dizi);
$sonuc = m_curl(
"http://url.com/", array('token' => $http_build_query)
);
echo $sonuc;