Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8318937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:08:56+00:00 2026-06-08T22:08:56+00:00

So I’m trying to retrieve an access_token from bit.ly to use their url shorten

  • 0

So I’m trying to retrieve an access_token from bit.ly to use their url shorten API call. Everytime I make the curl call I get INVALID_CLIENT_ID as a response. I quadruple checked, all my keys are fine. What could be happening?

Here is the code:

define('BITLY_CLIENT_ID','xxx');
define('BITLY_CLIENT_SECRET','xxx');
define('BITLY_API_KEY','xxx');

function curl($url, $params) {

    $params_str = http_build_query($params);
    $curl = curl_init();
    $header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
    $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
    $header[] = "Cache-Control: max-age=0";
    $header[] = "Connection: keep-alive";
    $header[] = "Keep-Alive: 300";
    $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
    $header[] = "Accept-Language: en-us,en;q=0.5";
    $header[] = "Pragma: "; // browsers keep this blank.

    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
    curl_setopt($curl, CURLOPT_POST,count($params));
    curl_setopt($curl, CURLOPT_POSTFIELDS,urlencode($params_str));
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

    $rs = curl_exec($curl);
    curl_close($curl);
    return $rs;
}

$access_token = curl('https://api-ssl.bitly.com/oauth/access_token',array('client_id'=>BITLY_CLIENT_ID,'client_secret'=>BITLY_CLIENT_SECRET,'x_auth_username'=>'MY_USERNAME','x_auth_password'=>'MY_PASSWORD'));

echo $access_token;exit; // Returns INVALID_CLIENT_ID
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T22:08:58+00:00Added an answer on June 8, 2026 at 10:08 pm

    So I emailed Bit.ly earlier today (Awesome service btw, quick and polite), this is the response they gave to me:

    If all you’re looking to do is to get an access_token for your own account, I suggest using the basic auth mechanism documented at http://dev.bitly.com/authentication.html. Just load up terminal and curl the following URL w/ your username and password:

    curl -u “username:password” -X POST “https://api-ssl.bitly.com/oauth/access_token”

    So run this and copy and paste your access_token into your config.

    My new curl call looked like this:

    curl('https://api-ssl.bitly.com/v3/shorten',array('apiKey'=>BITLY_API_KEY,'access_token'=>BITLY_ACCESS_TOKEN,'longUrl'=>'http://www.google.com'))
    

    P.S – urlencoding the $params_str broke the call too. Thanks timoh!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.