I'm playing a bit with Php recently and came across an error I coundn't help my self. So i wrote in Python the follwing Code:
import os
import requests
import urllib
s = requests.Session()
s.get('https://profile.callofduty.com/cod/login')
data = {'username': 'My@Email.com',
'password': 'myPassword',
'remember_me': 'true',
'_csrf': s.cookies['XSRF-TOKEN']}
s.post('https://profile.callofduty.com/do_login?new_SiteId=cod', params=data)
print(s.cookies)
For Obivous reasons this aint my real data.
In Php I wrote the following:
<?php
var_dump($_POST["X-CSRFToken"]);
$ch = curl_init();
$url = 'https://profile.callofduty.com/do_login?new_SiteId=cod';
$datihfbskdhfibfa = array(
'username' => 'My@Email.com',
'password' => 'MyPassword',
'remember_me' => 'true',
'_csrf' => $_POST["X-CSRFToken"]
);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $datihfbskdhfibfa);
$server_output = curl_exec($ch);
echo $server_output;
curl_close ($ch);
Before I do the POST request, I receive the X-CSRF from another Php file and pass it through JS to this php File. If I run Python I receive the Token, with Php it throws me a 403 Forbidden back. Can someone explain me why there is an issue?