• Hi,
    I would like to be able to use a URL to grab variables from an external link and to then insert these variables into a link in the post that the external link is linking to.
    Say the external link on another website is: https://www.myblog.com/a-test-post.php?m=test&aa=test2

    I would then have some code in the plugin, like

    if(isset($_GET['link'])){
    	$m=$_GET['link'];
    }
    if(isset($_GET['aa'])){
    	$aa=$_GET['aa'];
    }
    $link="https://www.gohere.com/index.php?m=$m&aa=$aa";

    What I would like to do is then be able to insert link in my post, using some sort of tag, e.g. {mylink}

    How would I write such a plugin?

    Thanks.
    Steve

Viewing 3 replies - 1 through 3 (of 3 total)
  • I’m not sure I understand.
    $_GET will check the url of your blog not an external url.
    If you know the external url, then just parse it and create your own link.
    Now, if you want to grab the url whence the call is, you need to use $_SERVER[“HTTP_REFERER”] (and then parse it^^).

    Thread Starter chemoul

    (@chemoul)

    well, referrer could be any referal url, not just from one specific domain.
    I’ve got another domain where links point to my blog. So the link on that other domain would be something like https://www.myblog.com/a-test-post.php?m=test&aa=test2
    I want to be able to parse the variables in this url to the php code described above, which is located in a plugin and then insert these variables in a different link that’s in my blog post.

    Start with the PHP parse_url() function.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘plugin to pass variables from external URL using $_GET’ is closed to new replies.