Falicon / BitlyPHP

A simple PHP library for interacting with the Bit.ly API (including the new OAuth endpoints)
http://falicon.com
189 stars 134 forks source link

returning "Array" #12

Open maxmitch opened 10 years ago

maxmitch commented 10 years ago

require_once('bitly.php');

$results = bitly_v3_shorten('http://www.tragicclothing.co.uk/bitsandbobs.php#martello-tower-y-by-billings-jackson-design', '83dsfreu61b8b7081e950d6c1383fb86d3d8334', 'j.mp');

when I use echo $results; the php page returns Array.

And when I use echo $results[0]; the php page returns nothing?

Why is this not working?

Falicon commented 10 years ago

its prob. a ref. array...try $results->[0] and see if that returns what you would expect.

Sent from my iPad

On Jun 21, 2014, at 6:18 AM, Max Mitchell notifications@github.com wrote:

require_once('bitly.php');

$results = bitly_v3_shorten('http://www.tragicclothing.co.uk/bitsandbobs.php#martello-tower-y-by-billings-jackson-design', '83dsfreu61b8b7081e950d6c1383fb86d3d8334', 'j.mp');

when I use echo $results; the php page returns Array.

And when I use echo $results[0]; the php page returns nothing?

Why is this not working?

— Reply to this email directly or view it on GitHub.

maxmitch commented 10 years ago

I did try $results[0] ?

Falicon commented 10 years ago

The difference is the arrow before the bracket $results->[0] vs $ results[0]

The first is for a reference to an array, the second is actually an array...it's a confusing thing that mostly has to do with memory management in the background.

I did try $results[0] ?

— Reply to this email directly or view it on GitHub https://github.com/Falicon/BitlyPHP/issues/12#issuecomment-46758786.

websolprov commented 10 years ago

I have the same problem, it was working previously, and I tested that curl is working:

function _isCurl(){ return function_exists('curl_version'); }

echo "Curl enabled: " . _isCurl();

I even tried changing the $var->{}->{} notation to $var[][] and still nothing, when i print_r the output I just get:

Array ( [status_code] => )

websolprov commented 10 years ago

If I echo display the url that is passed to curl and then put this into a browser I get a successful shortlink, and a 200 status code but it doesnt explain how or why the php curl call doesnt work.

websolprov commented 10 years ago

If I print the $ch variable I get Resource id #53 so this isnt generating an error, but if I execute:

$output = curl_exec($ch);
echo "output: ";
print_r($output);

I just get blank, no errors.

websolprov commented 10 years ago

Hmmm seems to be that CurlSSL wasnt enabled on the server, did this in Apache and the SSL call to the shorten function seems to work now.

dotcomUNDERGROUND commented 9 years ago

I am also getting the same error.

code: include_once('bitly.php'); $result = bitly_v3_shorten('http://getbootstrap.com/2.3.2/'); print_r($result);

result shows: Array ( )

I have checked phpinfo() and curls shows up enabled with ssl

dotcomUNDERGROUND commented 9 years ago

I tried again by uploading the file again and creating a new test file.

code: <?php include_once('bitly.php'); $result = bitly_v3_shorten('http://knowabout.it', 'j.mp'); print_r($result); ?>

result: Array ( [status_code] => 500 )

Falicon commented 9 years ago

The result is an array because there appears to be an error (the status_code listed at 500)...that specific error probably has to do with authentication (i.e. you are not properly authorized when you make the request)...it looks like the 'shorten' endpoint now requires auth ( http://dev.bitly.com/links.html#v3_shorten ).

On Sat, May 16, 2015 at 5:22 PM, dotcomUNDERGROUND <notifications@github.com

wrote:

I tried again by uploading the file again and creating a new test file.

code: <?php include_once('bitly.php'); $result = bitly_v3_shorten('http://knowabout.it', 'j.mp'); print_r($result); ?>

result: Array ( [status_code] => 500 )

— Reply to this email directly or view it on GitHub https://github.com/Falicon/BitlyPHP/issues/12#issuecomment-102699533.

dotcomUNDERGROUND commented 9 years ago

I have the following properly set: bitlyKey bitlyLogin bitly_clientid bitly_secret

websolprov commented 9 years ago

WHy on earth am I being copied to all this? remove me immediately!

From: Kevin Marshall [mailto:notifications@github.com] Sent: 17 May 2015 01:04 To: Falicon/BitlyPHP Cc: Alex Cope-Norris - WebSolProv Subject: Re: [BitlyPHP] returning "Array" (#12)

The result is an array because there appears to be an error (the status_code listed at 500)...that specific error probably has to do with authentication (i.e. you are not properly authorized when you make the request)...it looks like the 'shorten' endpoint now requires auth ( http://dev.bitly.com/links.html#v3_shorten ).

On Sat, May 16, 2015 at 5:22 PM, dotcomUNDERGROUND <notifications@github.com mailto:notifications@github.com%0b> wrote:

I tried again by uploading the file again and creating a new test file.

code: <?php include_once('bitly.php'); $result = bitly_v3_shorten('http://knowabout.it', 'j.mp'); print_r($result); ?>

result: Array ( [status_code] => 500 )

— Reply to this email directly or view it on GitHub https://github.com/Falicon/BitlyPHP/issues/12#issuecomment-102699533.

— Reply to this email directly or view it on GitHubhttps://github.com/Falicon/BitlyPHP/issues/12#issuecomment-102712727.

nikokauranen commented 9 years ago

Getting the same error as above, the file returns just "Array". I've triple-checked everything, but still no luck, any idea what could be going on?

diogo10 commented 8 years ago

Hi guys, how can I get just the url? I've tried results[0], results->[0]....just to test if I can get some part of the array....but no luck.

phplicengine commented 4 years ago

Our lib is for Bitly Api v4. https://github.com/phplicengine/bitly