Opening of your website in the viewer’s external browser automatically instead of Instagram’s in-app browser (on Android devices).
You can solve it by acting as a file to be downloaded, then the in-app browser will redirect you to the mobile browser.
not working on iPhone. :(
PHP
<?php
$userAgent = $_SERVER['HTTP_USER_AGENT'];
if (strpos($userAgent, 'Instagram')) {
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename= blablabla');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');
@readfile($file);
die();
}
?>
ASP.NET Web API:
namespace DotNet.Controller
{
public class DummyBytesController : ApiController
{
[HttpGet]
public HttpResponseMessage Get()
{
HttpResponseMessage Response;
string UserAgent = HttpContext.Current.Request.UserAgent;
if(UserAgent.Contains("Instagram"))
{
Response = new HttpResponseMessage(HttpStatusCode.OK);
Response.Content = new ByteArrayContent(new byte[50]);
Response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
return Response;
}
else
{
Response = Request.CreateResponse(HttpStatusCode.Redirect);
Response.Headers.Location = new Uri("https://mywebsite.com");
return Response;
}
}
}
}