[insert_php]
$code = $_GET[‘code’];
$locations=’i4990026 i6011963 rs1042713 rs1042714 rs1048943 rs1056806 rs1056827 rs10857796 rs1130990 rs1138272 rs113846795 rs11553890 rs11553892 rs11553893 rs12097277 rs12796085 rs140309 rs140310 rs140311 rs149344762 rs1695 rs174546 rs17782313 rs17850155 rs1799883 rs1799945 rs1799983 rs1800562 rs1800566 rs1800629 rs1801131 rs1801133 rs1801282 rs1801394 rs1804666 rs1805087 rs1815739 rs1871042 rs2071487 rs2228145 rs2228570 rs2266635 rs2266636 rs2266637 rs234706 rs2844008 rs3804072 rs41462048 rs4147564 rs4147565 rs4147566 rs429358 rs448934 rs45557045 rs45575838 rs45613443 rs4680 rs4880 rs4988235 rs5031031 rs5082 rs57201490 rs5760163 rs6413486 rs6674567 rs72549312 rs731236 rs737497 rs7412 rs74837985 rs756637 rs762551 rs762803 rs7903146 rs8191445 rs968567 rs9939609′;
// We will post these fields to 23andMe.
$scope=’basic names email ‘.$locations;
$post_field_array = array(
‘client_id’ => ‘3dc6ca891c22a2a40f64a597a495ea43’,
‘client_secret’ => ’71e211192187e2b4093e78abf0107237′,
‘grant_type’ => ‘authorization_code’,
‘code’ => $code,
‘redirect_uri’ => ‘https://www.mydnahealth.co.uk/redirect23’,
‘scope’ => $scope);
// Encode the field values for HTTP.
$post_fields = ”;
foreach ($post_field_array as $key => $value)
$post_fields .= “$key=” . urlencode($value) . ‘&’;
$post_fields = rtrim($post_fields, ‘&’);
//get a valid access token
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ‘https://api.23andme.com/token/’);
curl_setopt($ch, CURLOPT_POST, count($post_field_array));
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$encoded_json = curl_exec($ch);
if(curl_errno($ch)){
throw new Exception(curl_error($ch));
}
curl_close($ch);

echo $encoded_json;
[/insert_php]