为外部网站发布者创建一个图片引用链接,以链接到我的网站 [英] Create an Image Trackback for an outside web publisher to link to my site

查看:95
本文介绍了为外部网站发布者创建一个图片引用链接,以链接到我的网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试创建一个引导系统,让外部网络发布商可以在网站上的某个网页上放置一些html,并将其链接到我们网站上的特定产品页面。我们称之为徽章。



一旦他们插入了徽章,我们想要识别它,然后抓住< h1>和第一<作为一个挑逗,包括从我们的网站链接到他们的链接,并将所有这些东西写入我们的数据库。然后,我们的用户可以看到他们页面的标题和第一位,然后决定他们是否希望看到更多。



这是我们所做的(没有太多我'害怕):

 < a href =http://www.mysite.com/abc.html> 
< img alt =abcsrc =http://www.mysite.com/logo.gifstyle =width:200px; height:100px/>
< / a>

我们计划建立一个管理页面来完成抓取< h1>和<然后将它发布到实时数据库等,我们将在稍后解决这个问题。

然而,中间步骤(确定这段html已经使用)我们处于亏损状态。



这是我们应该通过日志文件完成的事情......我不知道如何开始思考它。



从哪里开始处理这个问题的一个小方向将非常有用。

预先感谢!!

解决方案

这是一种方法。

HTML看起来像这样:

 < a href =http://www.mysite.com/abc.html > 
< img alt =abcsrc =http://www.mysite.com/logo.phpstyle =width:200px; height:100px/>
< / a>

请注意, logo.php ,不是 logo.gif



logo.php 在你的服务器上。它的目的是双重的:


  1. 收集关于持有< img> tag

  2. 加载并输出logo.gif,以便用户按预期查看图片。

如果您将该html嵌入到某个网页的某个网页中,logo.php将包含有关图像请求来源的信息。特别是, $ _ SERVER ['HTTP_REFERER'] 会为您提供img标签所在页面的完整URL。然后决定如何处理和存储这些信息。



我不知道你想要做什么,而是一个非常简化的logo.php看起来像这样:

 <?php 
$ url = $ _SERVER ['HTTP_REFERER'];

//用$ url做一些事情...
//它会像http://theirsite.com/wherever/they/pasted/the.html

//现在输出徽标图像...
header(Content-Type:image / gif);
echo file_get_contents(/ path / to / logo.gif);

请记住,每次使用图片标签时,任何人都会点击他们的页面,logo.php将会运行。所以不要不小心在您的网站上创建10000个链接返回到他们的网站:)


We're trying to create a trackback system where an outside web publisher can put some html on a page on their website that links back to a specific product page on our site. Let's call it a 'badge' for purposes of this question.

Once they've inserted the badge, we want to identify this, then grab the < h1 > and first < p > as a teaser to comprise a link from our site back to theirs and write all this stuff to our database. Then, our users can see the title and first bit of their page, then decide if they want to see more.

Here's what we've done (not much I'm afraid):

<a href="http://www.mysite.com/abc.html">
<img alt="abc" src="http://www.mysite.com/logo.gif" style="width:200px;height:100px" />       
</a>

We're planning to build an admin page to do the last part of grabbing the < h1> and < p> and posting it to the live database, etc. and we'll figure this out later.

However, the middle step (identifying that this piece of html has been used) we're at a loss.

Is this something we should be doing through a log file....I have no clue even how to begin thinking about it.

A little direction of where to begin working on this problem would be very helpful.

Thanks in advance!!

解决方案

This is one approach.

You give them HTML which looks something like:

<a href="http://www.mysite.com/abc.html">
    <img alt="abc" src="http://www.mysite.com/logo.php" style="width:200px;height:100px" />       
</a>

Notice that says logo.php, not logo.gif.

logo.php will live on your server. Its purpose is twofold:

  1. Gather information about the page holding the <img> tag
  2. Load and output logo.gif so the users see the image as expected.

If you embed that html on a webpage somewhere, logo.php will have information about where the request for the image originated. Specifically, $_SERVER['HTTP_REFERER'] will give you the complete URL to the page where the img tag resides. It is then up to you to decide how to process and store that information.

I don't know exactly what you want to do, but a very simplified logo.php would look something like this:

<?php
$url = $_SERVER['HTTP_REFERER'];

// do something with $url... 
// it will be something like "http://theirsite.com/wherever/they/pasted/the.html"

// now output the logo image...
header("Content-Type: image/gif");
echo file_get_contents("/path/to/logo.gif");

Keep in mind that every time anyone hits their page with the image tag, logo.php will be run. So don't accidentally create 10000 links back to their site on your site :)

这篇关于为外部网站发布者创建一个图片引用链接,以链接到我的网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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