Google URL Shortener API Not Working

12 views
Skip to first unread message

Vishal Mohla via StackOverflow

unread,
Jan 8, 2015, 9:19:41 AM1/8/15
to google-appengin...@googlegroups.com

I Keep getting this error despite making many apps and also signing up for a free account. The objective was to create URL Shortener:

stdClass Object ( [error] => stdClass Object ( [errors] => Array ( [0] => stdClass Object ( [domain] => usageLimits [reason] => userRateLimitExceededUnreg [message] => User Rate Limit Exceeded. Please sign up [extendedHelp] => https://code.google.com/apis/console ) ) [code] => 403 [message] => User Rate Limit Exceeded. Please sign up ) ) 

Following is the code:

$apiKey='......';   
$url='http://www.example.com';

function httpsPost($postDatas)
{
    $jsonData = json_encode($postDatas);
    //echo $jsonData."<br><br>";
    $curlObj = curl_init();
    curl_setopt($curlObj, CURLOPT_URL, "https://www.googleapis.com/urlshortener/v1/url");
    curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curlObj, CURLOPT_HEADER, 0);
    curl_setopt($curlObj, CURLOPT_HTTPHEADER, array('Content-type:application/json'));
    curl_setopt($curlObj, CURLOPT_POST, 1);
    curl_setopt($curlObj, CURLOPT_POSTFIELDS, $jsonData);

    $response = curl_exec($curlObj);

    //change the response json string to object
    $json = json_decode($response);
    curl_close($curlObj);

    return $json;
}

$postData = array('longUrl' => $url,'key' => $apiKey);
        $info = httpsPost($postData);
        print_r($info);
        //die();
        if($info->id)$shorturl=$info->id;else $shorturl="Unsuccessful";
        echo "<br><br> Short URL: ".$shorturl;


Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/27842193/google-url-shortener-api-not-working

Vishal Mohla via StackOverflow

unread,
Jan 10, 2015, 5:07:37 AM1/10/15
to google-appengin...@googlegroups.com

I Keep getting this error despite making many apps and also signing up for a full account. The objective was to create URL Shortener:

  • userRateLimitExceededUnreg
  • User Rate Limit Exceeded. Please sign up
  • 403

Vishal Mohla via StackOverflow

unread,
Jan 15, 2015, 12:04:42 AM1/15/15
to google-appengin...@googlegroups.com

The following solved the problem

https://www.googleapis.com/urlshortener/v1/url?key=.......



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/27842193/google-url-shortener-api-not-working/27957092#27957092
Reply all
Reply to author
Forward
0 new messages