Background: According to Bitly's API documentation, when a link is shortened via their API, it should be shortened using the domain that the authenticated user has set as their default domain if no domain is specified in the API request.
Parameters
longUrl - a long URL to be shortened (example: http://betaworks.com/).
domain - (optional) the short domain to use; either bit.ly, j.mp, or bitly.com or a custom short domain. The default for this parameter is the short domain selected by each user in their bitly account settings. Passing a specific domain via this parameter will override the default settings.
format - json, xml, txt. Default: json.
Quote taken from Bitly's API documention found here: https://dev.bitly.com/links.html#v3_shorten
Problem: In my plugin, however, it ALWAYS returned the link shortened in the bit.ly format and NEVER returns a link shortened using the a custom short domain. This is the case both in my testing and for several other users who use this scrip.
Context: You can see my function starting on line 203 of this GitHub file here: https://github.com/warfare-plugins/social-warfare/blob/master/functions/bitly.php
You can see that actual API request being built down on line 230.
I tried manually declaring the domain parameter, and it still failed to produce the desired results.
Question: So how do I get it to use the user's default domain name instead of always using the bit.ly domain name?