load image url from instagram - php

Currently i want to get image from instagram url. the url is this
https://www.instagram.com/p/B_zZCRpB895/media/?size=t
what im doing now is this :
$image = file_get_contents("https://www.instagram.com/p/B_zZCRpB895/media/?size=t");
i run it into my AWS server, but the result is go to login instagram.
<!DOCTYPE html>\n
<html lang="en" class="no-js not-logged-in client-root">\n
<head>\n
<meta charset="utf-8">\n
<meta http-equiv="X-UA-Compatible" content="IE=edge">\n
\n
<title>\n
Login • Instagram\n
</title>\n
\n
\n
<meta name="robots" content="noimageindex, noarchive">\n
<meta name="apple-mobile-web-app-status-bar-style" content="default">\n
<meta name="mobile-web-app-capable" content="yes">\n
<meta name="theme-color" content="#ffffff">\n
<meta id="viewport" name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, viewport-fit=cover">\n
<link rel="manifest" href="/data/manifest.json">\n
......
however, if i run into my local PC. i can display the image code. is there any way to get the image code from the url instagram?

It think it because these links are designed to serve content on instagram site. So if you want to display images on your site you have to use instagram api instead:
Here is getting started link for instagram api.
You will end most likly using this endpoint: graph.facebook.com/{image id} after you have provided a authenication token too.

Related

How to get information from a url

Is there a way to get link information through a link (title, subtitle, detail, pictures)?
Like the telegram and LinkedIn in telegram or LinkedIn when you put some link for posting or sending to channel or group you can see some detail of that link.
How can I do this for php code?
The only way to get information about that link is to crawl the page and then extract the data from special meta tags (<meta property="og:...") in the header, then display it accordingly. Perhaps you need a ready-made package that can do this, or even with jQuery you should be able to parse it. Below is the example of the tages generated on the current page:
<meta property="og:type" content="website">
<meta property="og:url" content="https://stackoverflow.com/questions/58146161/ability-to-get-article-link-information/58146431">
<meta property="og:site_name" content="Stack Overflow">
<meta property="og:image" itemprop="image primaryImageOfPage" content="https://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon#2.png?v=73d79a89bded">
<meta name="twitter:card" content="summary">
<meta name="twitter:domain" content="stackoverflow.com">
<meta name="twitter:title" property="og:title" itemprop="name" content="Ability to get article link information">
<meta name="twitter:description" property="og:description" itemprop="description" content="The only way to get information about that link is to crawl the page and then extract the data from special meta tags (&lt;meta property="og:...") in the header, then display it accordingly. Perha...">
<meta name="twitter:app:country" content="US">
<meta name="twitter:app:name:iphone" content="Stack Exchange iOS">
<meta name="twitter:app:id:iphone" content="871299723">
<meta name="twitter:app:url:iphone" content="se-zaphod://stackoverflow.com/questions/58146161/ability-to-get-article-link-information/58146431">
<meta name="twitter:app:name:ipad" content="Stack Exchange iOS">
<meta name="twitter:app:id:ipad" content="871299723">
<meta name="twitter:app:url:ipad" content="se-zaphod://stackoverflow.com/questions/58146161/ability-to-get-article-link-information/58146431">
<meta name="twitter:app:name:googleplay" content="Stack Exchange Android">
<meta name="twitter:app:url:googleplay" content="http://stackoverflow.com/questions/58146161/ability-to-get-article-link-information/58146431">
<meta name="twitter:app:id:googleplay" content="com.stackexchange.marvin">

facebook share link not show fetured image

when i share my site post in facebook then not show that post featured image in facebook. show different default image. how i can solve this? my site link
i already use this open graph code.. but it's not work
<meta property="og:title" content="Bangladesh Time">
<meta property="og:type" content="website">
<meta property="og:url" content="http://bangladeshtime.com/">
<meta property="og:image" content="http://bangladeshtime.com/_files/mainlogo.png" />
<meta property="og:description" content="">
<meta property="og:site_name" content="Bangladesh Time">
Your image is to small. The minimum image size is 200*200px regarding to the documentation.
Edit: In your website's markup i can't find the open graph tags. In addition, your markup is invalid:
<center><img src='http://bangladeshtime.com/head-test-eng.jpg'></center>
<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
...

Post swf in user facebook timeline not working

I want to post swf file within user Facebook timeline but seems I am missing something. Only image is display not the swf file. Plz help what I am doing worng
var obj = {
method: 'feed',
link: 'share-page.php',
picture: 'uploads/pics/a.png',
source: 'assets/swf/preloader.swf',
name : 'name',
caption: 'Caption',
description: 'Description'
};
function callback(response) {
//some code here
}
FB.ui(obj, callback);
And my share-page.php file
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="content-language" content="en">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<!-- Open grah tags for Facebook -->
<meta property="og:title" content="Test video player" />
<meta property="og:description" content="A video player interface experiment." />
<meta property="og:type" content="video" />
<meta property="og:url" content="share-page.php"/>
<meta property="og:image" content="uploads/pics/a.png"/>
<meta property="og:video" content="assets/swf/preloader.swf" />
<meta property="og:video:secure_url" content="assets/swf/preloader.swf" /> <meta property="og:video:width" content="325" />
<meta property="og:video:height" content="180" />
<meta property="og:video:type" content="application/x-shockwave-flash" />
</html>
I wish I saw your question sooner...
See my answer to this question and hopefully it will help you.
Your main issue is you just put folder names (Assets and Uploads) without even saying what website/server they come from. You need a full path to files:
<meta property="og:url" content="http://www.yoursite.com/share-page.php"/>
<meta property="og:image" content="http://www.yoursite.com/uploads/pics/a.png" />
<meta property="og:video" content="http://www.yoursite.com/assets/swf/preloader.swf" />
<meta property="og:video:secure_url" content="HTTPS://www.yoursite.com/assets/swf/preloader.swf" />
Basically you should be able to paste exact same path into a new browser tab and see a working result otherwise it wont work anywhere else including Facebook. Also you need the SWF file mentioned in both "og:video" and "og:video:secure_url" tags to be coming from a genuine HTTPS server or it won't run within your timeline post (instead it opens new tab to your link).
Only image is display sounds like a lucky mistake!! Most likely because in your wall you're posting a link to your html page? Just so happens that Facebook also scans such links for a display image (It's usually random but I guess for you the shown pic WAS the only one available to find there??)

Why does my Website Pictures does not show on Facebook thumbnail when i share it?

I have An Opencart Shop, I made a good few changes on it, then now every time I try sharing a page from my website it gets everything but my Images.
Here is my header
<head>
<script type="text/javascript" src="//ct1.addthis.com/static/r07/auth016.js"></script>
<link rel="stylesheet" type="text/css" href="//ct1.addthis.com/static/r07/widget119.css" media="all">
<style media="screen"></style>
<meta http-equiv="X-UA-Compatible" content="IE=9">
<meta property="og:title" content="3.5mm to 3.5mm Plug Audio Cable - (120cm)">
<meta property="og:type" content="website">
<meta property="og:site_name" content="IT Bargain">
<meta property="og:image" content="http://grabyourbargain.com/image/data/sku_283716_1.jpg">
<meta property="og:url" content="http://grabyourbargain.com/index.php?route=product/product&product_id=2554">
<meta property="og:description" content=" My Description">
I have used the debug FB tool already it has my picture there but it doesn't show me i can click and it will open but it doesn't actually show me at the debugger page. could someone Help me plz!
Here is the link of the results of FB debugger for my page
Because you've entered the wrong image path, http://grabyourbargain.com/image/data/sku_283716_1.jpg is not accesible, on a quick check you have entered the wrong path (cache - folder is missing), and also the size of the product image, like this: http://grabyourbargain.com/image/cache/data/sku_283716_1-350x350.jpg

Facebook Open Graph Stories using backend server on Wordpress

I am currently trying to set up the ability to publish open graph stories for an app but I am running into trouble with facebook's scraper. *Note: I am replacing the values in the parenthesis with their correct values; the php is hosted on wpengine.
I have put the example php code
(mydomian)/opengraph.php and when I enter (mydomian)/opengraph.php?fb:app_id=(my_id)&og:type=(type)&og:title=(title)&og:description=(descr)&og:image=(image)&body=(body) it generates the object as expected.
Unfortunately when I run it through the debugger I get:
Errors That Must Be Fixed
Object Missing a Required Value: Object at URL '(mydomain).wpengine.com/opengraph.php' of type 'website' is invalid because a required property 'og:type' of type 'string' was not provided.
Redirect Path
original: (mydomian).wpengine.com/opengraph.php?fb:app_id=(my_id)&og:type=(type)&og:title=(title)&og:description=(descr)&og:image=(image)&body=(body) it generates the object as expected.
301: (mydomain).wpengine.com/opengraph.php //looks like it's redirecting and scraping this page instead
the end result of the scrape is
<!DOCTYPE html>
<html>
<head prefix="og: http://ogp.me/ns# product: http://ogp.me/ns/product#">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta property="fb:app_id" content="">
<meta property="og:url" content="(mydomain).wpengine.com/opengraph.php">
<meta property="og:type" content="">
<meta property="og:title" content="">
<meta property="og:image" content="">
<meta property="og:description" content="">
<title>Product Name</title>
</head>
<body>
</body>
</html>
Like I said before when I visit this page via web browser myself the html contains the correct values, but for some reason the facebook scraper is getting just the base php with no input. Any ideas?
Decided to go around the problem and use our plugin to generate the meta properties per post instead. If anyone else comes across this issue, the code at http://www.wpbeginner.com/wp-themes/how-to-add-facebook-open-graph-meta-data-in-wordpress-themes/ seems to be working for our purposes. We generate a bunch of xml from custom post types for our app and that's what we needed to publish stories about.

Categories