iheartbreakz's Profile User Rating: -----

Reputation: 1 Apprentice
Group:
Active Members
Active Posts:
196 (0.16 per day)
Joined:
27-April 11
Profile Views:
1,646
Last Active:
User is offline Jun 15 2014 03:46 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   iheartbreakz has not set their status

Posts I've Made

  1. In Topic: bit.ly api onclick function

    Posted 12 Apr 2014

    This is my next approach: I am trying to use PHP to send the API and username for security purposes and I think I am doing that succesfully but I think my code is a little messy... How can I make my code more efficient? Also I have to use return trim($data); instead of return ($data); because there is an automatic line break after my url.. why is that?

    <?php
    function get_bitly_short_url($url,$format='txt')
    { $connectURL = 'http://api.j.mp/v3/shorten?login=(MY USERNAME)&apiKey=(MY API)&uri='.urlencode($url).'&format='.$format; return curl_get_result($connectURL);}
    function curl_get_result($url) {
    $ch = curl_init();
    $timeout = 5;
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
    $data = curl_exec($ch);
    curl_close($ch);
    return trim($data);
    }
    $short_url = get_bitly_short_url('http://google.com');
    ?>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script>
    function getShortURL(url) {
        $("#bitly_input").show();
        $("#bitly_button").hide();
        document.getElementById("bitly_input").value = '<? echo $short_url ?>';
    };
    </script>
        <input type="submit" id="bitly_button" value="Fetch" onclick="getShortURL('<?php echo $short_url ?>')" />
        <input type="text" name="bitly_input" id="bitly_input" style="display:none;" onclick="this.select()" value="fetching" />
    
  2. In Topic: bit.ly api onclick function

    Posted 11 Apr 2014

    Ah, I see my mistake... I solved the problem. It works as I wanted now! :)
  3. In Topic: bit.ly api onclick function

    Posted 11 Apr 2014

    So how can I fix the code because I tried using a different name for the parameter but it still didn't work
  4. In Topic: bit.ly api onclick function

    Posted 11 Apr 2014

    on Console I don't have erros but it just isn't passing on the values I debugged it using the console log... Can you check my code in the first post and verify?
  5. In Topic: bit.ly api onclick function

    Posted 11 Apr 2014

    But the values weren't getting passed the Javascript part wasn't working

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

iheartbreakz hasn't added any friends yet.

Comments

iheartbreakz has no profile comments yet. Why not say hello?