facebook og:image无法从呼应URL的php文件中获取图像 [英] facebook og:image does not fetch image from php file that echoes the URL

查看:148
本文介绍了facebook og:image无法从呼应URL的php文件中获取图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

facebook OG从回显的URL中获取图像,这可能吗?

facebook OG fetch image from echoed URL, is this possible?

因为我包含了一个将回显图像URL的php文件,但是当我检查共享调试器"时,内容为空

since I included a php file that will echo the image URL but when I check in Sharing debugger the content is empty

<meta property="og:image" content="" />

我的元标记 :

<meta property="og:image" content ="<?php include "meta_gambar.php"?>">

和php文件:

<?php
 $module=$_GET['module'];
 $id=$_GET['id'];
 if($module=='detailproduk'){
   //prepare query
   $stmt=mysqli_prepare($con,"SELECT gambar FROM produk WHERE id_produk=?");
    if($stmt===false){
       die("Prepare error" . htmlspecialchars($mysqli->error));
    }
    //Bind parameters
    $bp=mysqli_stmt_bind_param($stmt,"i",$id);
     if($bp===false){
        die("Binding error" . htmlspecialchars($stmt->error));
    }
     //Execute query
     $bp=mysqli_stmt_execute($stmt);
     if($bp===false){
         die("Execute error" . htmlspecialchars($stmt->error));
     }
     //bind result
     $bp=mysqli_stmt_bind_result($stmt,$gambar);
      if($bp===false){
          die("Result bind error" . htmlspecialchars($stmt->error));
      }
     //Fetch
      $bp=mysqli_stmt_fetch($stmt);
       if($bp===false){
           die("Fetching error" .htmlspecialchars($stmt->error));
      }
    $image = "http://images.rajafotocopy.com/foto_produk/$gambar";
   }else{
      $image = "http://images.rajafotocopy.com/raja.png";
 }
   echo"$image";
?>

更新

我只是尝试将直接URL图像放到og:image content上,并且有效

I just tried putting a direct URL image to the og:image content and it works

但包含将回显URL的php文件仍然会导致空白

but including a php file that will echo the URL still results in blank

推荐答案

类似当前路径的声音不在包含文件所在的位置.尝试指定包含文件的完整路径,例如:

Sounds like the current path is not where the include file is. Try specifying the full path to the include file, eg:

include $_SERVER['DOCUMENT_ROOT'] . "/path/to/meta_gambar.php";

另一种选择是使用require而不是include-如果文件或路径有问题,require会生成错误并为您提供一些有关错误之处的提示.

Another option is to use require instead of include - if there is a problem with the file or path, require will generate an error and give you some ideas about what is wrong.

这篇关于facebook og:image无法从呼应URL的php文件中获取图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆