Is it still possible to use Itunes Connect API endpoints instead of Java Reporter tool?

979 views Asked by At

Prior to the newest Itunes Connect update all requests were HTTP requests made through Curl in our application. After the update, Apple is recommending to use their new reporter tool.

https://github.com/mikebarlow/itc-reporter I want to do something similar to this if possible. This supposedly works without the reporter tool and it looks like it is still just making HTTP requests. I won't use this code in my project because it requires us to update PHP version which we have planned for another time.

Is it possible to make simple HTTP requests using Curl to get data? I don't want to use Guzzle if I don't have to!

$json = '{"userid":"{{USERNAME}}","password":"{{PASSWORD}}","version":"2.0","mode":"Robot.XML","account":"{{VENDOR_ID}}","queryInput":"[p=Reporter.properties, Sales.getReport, {{VENDOR_ID}},Sales,Summary,Weekly,20170108]"}'

CURLOPT_URL => 'https://reportingitc-reporter.apple.com/reportservice/sales/v1',
CURLOPT_HEADER => false,   
CURLOPT_HTTPHEADER => array('Accept: text/xml, text/plain', 'Content-Type: text/xml, text/plain'),  
CURLOPT_USERAGENT => 'Java/1.8.0_92',  
CURLOPT_TIMEOUT => 10,  
CURLOPT_SSL_VERIFYPEER => false,  
CURLOPT_POST => true,  
CURLOPT_POSTFIELDS => $json,

this is the request I've made while testing and when I run it I get the HTML response saying "Forbidden, You do not have access to this page"

I tried this while urlencoding username and password but I get the same result. I would love to be able to still get this data using Curl or we will have to work on adding the reporter tool into our application.

1

There are 1 answers

0
Derek Joseph Olson On BEST ANSWER

the postfield just needed to be changed accordingly

function build_json_request(, $access_token, $account_id, 
$args_arr=array())
{
    $args = $args_arr;

    $json = array(
        'accesstoken' => urlencode($access_token),
        'version'  => '2.2',
        'mode'     => 'Robot.XML',
        'account'  => $account_id
    );

    $queryInput = array(
        'p=Reporter.properties',
        array_shift($args)
    );

    if(! empty($args))
        $queryInput[] = implode(',', $args);

    $json['queryInput'] = '[' . implode(', ', $queryInput) . ']';

    return json_encode($json);
}

$json = build_json_request('Sales.getReport', $access_token, $account_id, array('Sales.getReport', $vendor_id, 'Sales', 'Summary', 'Daily', $date) );

    $output = process_curl(array(
        CURLOPT_URL => 'https://reportingitc-reporter.apple.com/reportservice/sales/v1',
        CURLOPT_HEADER => false,
        CURLOPT_TIMEOUT => 10,
        CURLOPT_SSL_VERIFYPEER => false,
        CURLOPT_POST => true,
        CURLOPT_POSTFIELDS => 'jsonRequest='.$json,
    ));