Forum Discussion

Michael_K's avatar
Michael_K
Experienced Partner
2 years ago

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>";

  • Hi Michael_K

     

    Thanks for your post.

     

    For any API error/integration-related queries, we recommend raising a support request via the following link: https://apisupport.myob.com/hc/en-us/requests/new

     


    Please don't hesitate to post again if you need help in the future.

     

    If my response has answered your enquiry please click "Accept as Solution" to assist other users find this information.

     

    Cheers,
    Leneth