1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

custom droid.ws php shorterner into forums

Discussion in 'PHP' started by stilv, Mar 28, 2013.

  1. #1
    i just finished making this code to work, but having a hard time making it look good

    Code (Text):
    1.  
    2. <?php
    3.  
    4.  
    5. function curPageURL() {
    6. $pageURL = 'http';
    7. if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
    8. $pageURL .= "://";
    9. if ($_SERVER["SERVER_PORT"] != "80") {
    10. $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
    11. } else {
    12. $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    13. }
    14. return $pageURL;
    15. }
    16.  
    17. function droidwsURL($url) {
    18.  
    19. $ch = curl_init();
    20.  
    21. curl_setopt($ch, CURLOPT_URL, "http://droid.ws/api.php?url=".urlencode($url));
    22. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    23. curl_setopt($ch, CURLOPT_HEADER, 0);
    24.  
    25. $shorturl = curl_exec ($ch);
    26. curl_close ($ch);
    27.  
    28. return $shorturl;
    29.  
    30. }
    31.  
    32. ?>
    33.  
    Code (Text):
    1.  
    2. <?php
    3. echo droidwsURL (curPageURL());
    4. ?>
    5.  
    working demo: http://stilv.com/test.php

    im trying to get now the <input feild to work or make it look like http://droid.ws input and have a button in the end says garb it


    any help will be great
    Last edited: Mar 28, 2013
    stilv, Mar 28, 2013 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,650
    Likes Received:
    22
    Best Answers:
    12
    Trophy Points:
    115
    #2
    add a form with a input button and let php do the work after $_SERVER['REQUEST_METHOD'] == "POST"
    EricBruggema, Mar 28, 2013 IP
  3. stilv

    stilv Banned

    Messages:
    156
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    80
    #3
    dont think i need $_post to get html to work here..
    stilv, Mar 29, 2013 IP
  4. stilv

    stilv Banned

    Messages:
    156
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    80
    #4
    go here: http://droidtweak.com/topic/248166-instamagic-for-instagram-view-your-friends-images-on-your-live-wallpaper/

    on the user details left of the post, you see share me with a bit.ly url , i like to replace that with code above
    stilv, Mar 29, 2013 IP
  5. stilv

    stilv Banned

    Messages:
    156
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    80
    #5
    any help will be great, thanks
    stilv, Apr 4, 2013 IP
  6. YoGem

    YoGem Active Member

    Messages:
    653
    Likes Received:
    6
    Best Answers:
    2
    Trophy Points:
    65
    #6
    Ok, let's start from the beginning.
    Are you trying to create a url shortening service? And you want to use the droid.ws API to accomplish it?
    Ok... so now, why what EricBrugemma was for you absurd? You may need a form! Unless you want to generate automatic URLS, right?

    Oh I think I got it! You want to automatically generate a short Link and post it in a forum for each new thread! Right?
    YoGem, Apr 5, 2013 IP
  7. stilv

    stilv Banned

    Messages:
    156
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    80
    #7
    that is correct, i have pm'ed EricBrugemma and he has been great on helping me get this to work
    stilv, Apr 5, 2013 IP
  8. YoGem

    YoGem Active Member

    Messages:
    653
    Likes Received:
    6
    Best Answers:
    2
    Trophy Points:
    65
    #8
    Great :) Good to know you had your issue fixed.
    YoGem, Apr 6, 2013 IP