<?php
$tokenrf=file_get_contents('rf');
$endpoint = 'https://star.api.edge.bamgrid.com/graph/v1/device/graphql';
$headers = [
    'Host: star.api.edge.bamgrid.com',
    'Accept: application/json',
    'Authorization: c3RhciZicm93c2VyJjEuMC4w.COknIGCR7I6N0M5PGnlcdbESHGkNv7POwhFNL-_vIdg',
    'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36',
    'Content-Type: application/json',
];

$data = '{"query":"\n     mutation registerDevice($registerDevice: RegisterDeviceInput!) {\n       registerDevice(registerDevice: $registerDevice) {\n         __typename\n       }\n     }\n     ","variables":{"registerDevice":{"applicationRuntime":"android","attributes":{"osDeviceIds":[{"identifier":"96c9f30c362665ad","type":"android.vendor.id"},{"identifier":"OUrSa5S9QjFeEZtRx0QfTDVjpGZp3pJeYs6XbGLvcKg=\n","type":"android.drm.id"},{"identifier":"a9be6699-f599-40ba-9772-1d86101588a2","type":"android.advertising.id"}],"manufacturer":"Xiaomi","model":"Mi 9T","operatingSystem":"Android","operatingSystemVersion":"11","brand":"Xiaomi"},"deviceFamily":"android","deviceLanguage":"pt","deviceProfile":"phone","devicePlatformId":"android"}},"operationName":"registerDevice"}';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $endpoint);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

$response = curl_exec($ch);
//Print_r($response);

if ($response === false) {
    echo "Falha na solicitação: " . curl_error($ch);
} else {
    $tk= (json_decode($response, true)['extensions']['sdk']['token']['accessToken']);
    $rf= (json_decode($response, true)['extensions']['sdk']['token']['refreshToken']);
$aa_endpoint = 'https://star.api.edge.bamgrid.com/v1/public/graphql';
$aa_headers = [
    'Host: star.api.edge.bamgrid.com',
    'Accept: application/json',
    'Authorization: '.$tk,
    'X-BAMSDK-Platform-ID: android',
    'X-Application-Version: 2.13.0-rc3.0',
    'X-BAMSDK-Client-ID: star-22bcaf0a',
    'X-BAMSDK-Platform: android/google/handset',
    'X-BAMSDK-Version: 8.1.3',
    'X-DSS-Edge-Accept: vnd.dss.edge+json; version=1',
    'X-BAMSDK-Transaction-ID: 4e92d9fb-ae33-47b0-be9d-b7b6d9994a6c',
    'User-Agent: BAMSDK/v8.1.3 (star-22bcaf0a 2.13.0-rc3.0; v4.0/v8.1.0; android; phone) Xiaomi Mi 9T (RKQ1.200826.002 test-keys; Linux; 11; API 30)',
    'Content-Type: application/json',
];

$aa_data = '{"operationName":"login","variables":{"input":{"email":"wesleysouto123@gmail.com","password":"vegeta123@"},"includePaywall":false,"includeIdentity":true},"query":"mutation login($input: LoginInput!, $includePaywall: Boolean!, $includeIdentity: Boolean!) { login(login: $input) { __typename account { __typename ...accountGraphFragment } actionGrant activeSession { __typename ...sessionGraphFragment } identity @include(if: $includeIdentity) { __typename ...identityGraphFragment } paywall @include(if: $includePaywall) { __typename ...paywallGraphFragment } } } fragment accountGraphFragment on Account { __typename id activeProfile { __typename id } profiles { __typename ...profileGraphFragment } parentalControls { __typename isProfileCreationProtected } flows { __typename star { __typename isOnboarded } } attributes { __typename email emailVerified userVerified locations { __typename manual { __typename country } purchase { __typename country } registration { __typename geoIp { __typename country } } } } } fragment profileGraphFragment on Profile { __typename id name personalInfo { __typename dateOfBirth gender } maturityRating { __typename ratingSystem ratingSystemValues contentMaturityRating maxRatingSystemValue isMaxContentMaturityRating } isAge21Verified flows { __typename star { __typename eligibleForOnboarding isOnboarded } } attributes { __typename isDefault kidsModeEnabled groupWatch { __typename enabled } languagePreferences { __typename appLanguage playbackLanguage preferAudioDescription preferSDH subtitleLanguage subtitlesEnabled } parentalControls { __typename isPinProtected kidProofExitEnabled liveAndUnratedContent { __typename enabled } } playbackSettings { __typename autoplay backgroundVideo prefer133 preferImaxEnhancedVersion } avatar { __typename id userSelected } } } fragment sessionGraphFragment on Session { __typename sessionId device { __typename id } entitlements experiments { __typename featureId variantId version } features { __typename coPlay download noAds } homeLocation { __typename countryCode adsSupported } inSupportedLocation isSubscriber location { __typename countryCode adsSupported } portabilityLocation { __typename countryCode } preferredMaturityRating { __typename impliedMaturityRating ratingSystem } } fragment identityGraphFragment on Identity { __typename id email attributes { __typename passwordResetRequired } flows { __typename marketingPreferences { __typename isOnboarded eligibleForOnboarding } personalInfo { __typename eligibleForCollection requiresCollection } } personalInfo { __typename dateOfBirth gender } locations { __typename purchase { __typename country } } subscriber { __typename subscriberStatus subscriptionAtRisk overlappingSubscription doubleBilled doubleBilledProviders subscriptions { __typename id groupId state partner isEntitled source { __typename sourceProvider sourceType subType sourceRef } product { __typename id sku name entitlements { __typename id name partner } bundle subscriptionPeriod earlyAccess trial { __typename duration } } stacking { __typename status overlappingSubscriptionProviders previouslyStacked previouslyStackedByProvider } term { __typename purchaseDate startDate expiryDate nextRenewalDate pausedDate churnedDate isFreeTrial } } } } fragment paywallGraphFragment on Paywall { __typename skus { __typename name sku entitlements productType groups subscription { __typename subscriptionPeriod sourceProvider } purchaseBehavior } paywallHash context assertions { __typename documentCode } }"}';

$aa_ch = curl_init();
curl_setopt($aa_ch, CURLOPT_URL, $aa_endpoint);
curl_setopt($aa_ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($aa_ch, CURLOPT_POST, true);
curl_setopt($aa_ch, CURLOPT_POSTFIELDS, $aa_data);
curl_setopt($aa_ch, CURLOPT_HTTPHEADER, $aa_headers);
curl_setopt($aa_ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($aa_ch, CURLOPT_SSL_VERIFYHOST, false);

$aa_response = curl_exec($aa_ch);

if ($aa_response === false) {
    echo "Falha na solicitação: " . curl_error($aa_ch);
} else {
    //echo $aa_response;
}
    $tkk= (json_decode($aa_response, true)['extensions']['sdk']['token']['accessToken']);
    $rff= (json_decode($aa_response, true)['extensions']['sdk']['token']['refreshToken']);
curl_close($aa_ch);
}
$aaa_endpoint = 'https://star.api.edge.bamgrid.com/v1/public/graphql';
$aaa_headers = [
    'Host: star.api.edge.bamgrid.com',
    'Accept: application/json',
    'Authorization: '.$tkk,
    'X-BAMSDK-Platform-ID: android',
    'X-Application-Version: 2.13.0-rc3.0',
    'X-BAMSDK-Client-ID: star-22bcaf0a',
    'X-BAMSDK-Platform: android/google/handset',
    'X-BAMSDK-Version: 8.1.3',
    'X-DSS-Edge-Accept: vnd.dss.edge+json; version=1',
    'X-BAMSDK-Transaction-ID: 4e92d9fb-ae33-47b0-be9d-b7b6d9994a6c',
    'User-Agent: BAMSDK/v8.1.3 (star-22bcaf0a 2.13.0-rc3.0; v4.0/v8.1.0; android; phone) Xiaomi Mi 9T (RKQ1.200826.002 test-keys; Linux; 11; API 30)',
    'Content-Type: application/json',
];

$aaa_data = '{"operationName":"switchProfile","variables":{"input":{"profileId":"4fa62055-b4a5-41b8-91ab-40e38943f70a"},"includeIdentity":true},"query":"mutation switchProfile($input: SwitchProfileInput!, $includeIdentity: Boolean!) { switchProfile(switchProfile: $input) { __typename account { __typename ...accountGraphFragment } activeSession { __typename ...sessionGraphFragment } identity @include(if: $includeIdentity) { __typename ...identityGraphFragment } } } fragment accountGraphFragment on Account { __typename id activeProfile { __typename id } profiles { __typename ...profileGraphFragment } parentalControls { __typename isProfileCreationProtected } flows { __typename star { __typename isOnboarded } } attributes { __typename email emailVerified userVerified locations { __typename manual { __typename country } purchase { __typename country } registration { __typename geoIp { __typename country } } } } } fragment profileGraphFragment on Profile { __typename id name personalInfo { __typename dateOfBirth gender } maturityRating { __typename ratingSystem ratingSystemValues contentMaturityRating maxRatingSystemValue isMaxContentMaturityRating } isAge21Verified flows { __typename star { __typename eligibleForOnboarding isOnboarded } } attributes { __typename isDefault kidsModeEnabled groupWatch { __typename enabled } languagePreferences { __typename appLanguage playbackLanguage preferAudioDescription preferSDH subtitleLanguage subtitlesEnabled } parentalControls { __typename isPinProtected kidProofExitEnabled liveAndUnratedContent { __typename enabled } } playbackSettings { __typename autoplay backgroundVideo prefer133 preferImaxEnhancedVersion } avatar { __typename id userSelected } } } fragment sessionGraphFragment on Session { __typename sessionId device { __typename id } entitlements experiments { __typename featureId variantId version } features { __typename coPlay download noAds } homeLocation { __typename countryCode adsSupported } inSupportedLocation isSubscriber location { __typename countryCode adsSupported } portabilityLocation { __typename countryCode } preferredMaturityRating { __typename impliedMaturityRating ratingSystem } } fragment identityGraphFragment on Identity { __typename id email attributes { __typename passwordResetRequired } flows { __typename marketingPreferences { __typename isOnboarded eligibleForOnboarding } personalInfo { __typename eligibleForCollection requiresCollection } } personalInfo { __typename dateOfBirth gender } locations { __typename purchase { __typename country } } subscriber { __typename subscriberStatus subscriptionAtRisk overlappingSubscription doubleBilled doubleBilledProviders subscriptions { __typename id groupId state partner isEntitled source { __typename sourceProvider sourceType subType sourceRef } product { __typename id sku name entitlements { __typename id name partner } bundle subscriptionPeriod earlyAccess trial { __typename duration } } stacking { __typename status overlappingSubscriptionProviders previouslyStacked previouslyStackedByProvider } term { __typename purchaseDate startDate expiryDate nextRenewalDate pausedDate churnedDate isFreeTrial } } } }"}';

$aaa_ch = curl_init();
curl_setopt($aaa_ch, CURLOPT_URL, $aaa_endpoint);
curl_setopt($aaa_ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($aaa_ch, CURLOPT_POST, true);
curl_setopt($aaa_ch, CURLOPT_POSTFIELDS, $aaa_data);
curl_setopt($aaa_ch, CURLOPT_HTTPHEADER, $aaa_headers);
curl_setopt($aaa_ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($aaa_ch, CURLOPT_SSL_VERIFYHOST, false);

$aaa_response = curl_exec($aaa_ch);

if ($aaa_response === false) {
    echo "Falha na solicitação: " . curl_error($aaa_ch);
} else {
    echo $aaa_response;
}
    $tkkk= (json_decode($aaa_response, true)['extensions']['sdk']['token']['accessToken']);
    $rffk= (json_decode($aaa_response, true)['extensions']['sdk']['token']['refreshToken']);
curl_close($aaa_ch);
$file = fopen('tk', 'w');
fwrite($file, $tkkk);
fclose($file);
$file2 = fopen('rf', 'w');
fwrite($file2, $rffk);
fclose($file2);
curl_close($ch);
?>
	