Accessing Online File via API
Hey guys,
We've been using the MYOB API on local network for years.
Unfortunately we're now forced to take our company file online.
I've been playing around with the following PHP code to get our access code from MYOB.
However, what happens is that the code redirects to a login page when I run the PHP code from our local server.
I need to get the code automatically so we can then proceed with connecting to the company file API.
Any idea how I can get the return code using PHP and without manually logging in each time an API request is made?
We have apps that run every 30 mins so manually logging in each time an API call is made is not practical. Surely there's a better way?
Thanks
------------------------------------------------------------------
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL, "https://secure.myob.com/oauth2/account/authorize?client_id=mpednfsn3vgd4gqs3a3g86rr&redirect_uri=http%3A%2F%2Fdesktop&response_type=code&scope=CompanyFile");
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$result = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
print "$httpCode\n";
print "<p>$result</p>";