jelovac / bitly4laravel

Provides a Laravel package to communicate with Bit.ly API
35 stars 18 forks source link

Running Shorten several times returns only the first run #20

Closed jedimdan closed 9 years ago

jedimdan commented 9 years ago

I have a code that runs Bitly::shorten($fullUrl) several times in a single request, each time with a different $fullUrl. Each time, the code would save the shortened bitly URL. However, instead of generating a unique short URL for each full URL, it returns the same short URL for all the other instances that run the same code.

This is the code that's run for each instance:

Log::info("Generating Bitly for $fullUrl");
$bitlyResponse = Bitly::shorten($fullUrl);
$bitly = $bitlyResponse['data']['url'];
$value = $this->attributes['bitly'] = $bitly;
Log::info($bitlyResponse);
Log::info("Bitly saved: $value");
$this->save();

return $value;

Tailing this code reveals that a unique long URL is provided, but the same short URL (from the first time it's run in the loop) is returned each time.

jelovac commented 9 years ago

Hi jedimdan,

Which Laravel version are you using and do you have cache enabled?

Sorry for late answer, had issues with my github account.

jedimdan commented 9 years ago

Hi @jelovac, I'm on Laravel 4.2.

jelovac commented 9 years ago

Hi jedimdan,

I tested it today on Laravel 4.2 with and without cache and everything looks ok.

Here is a test case that I did:

$links = array("http://google.com", "http://yahoo.com", "https://github.com/jelovac/bitly4laravel");

$shortLinks = array();

foreach($links as $link) {
    $data = Bitly::shorten($link);
    $shortLinks[] = $data['data']['url'];
}

var_dump($shortLinks);

The result:

http://bit.ly/17fgY4Z
http://yhoo.it/1GECLn8
http://bit.ly/1GEC02x
jedimdan commented 9 years ago

Hi @jelovac, strange, I just tested it again on my localhost and I can't seem to reproduce the issue any more. I can't test it on my production unfortunately, but if there was a problem on my production then it might be a problem with my cache rather than the package. Sorry for the trouble.

gpino-hash commented 8 years ago

Jelovac very good friend have a problem with your application that tells me : cURL Error 60: SSL certificate problem : unable to get the local issuer certificate