0

I'm trying to create a function to turn a link into a link to 'add link to Pocket' via getpocket.com/save.

I don't want to use the API and have users have to start logging in to their Pocket account - the /save link works if they're already logged in on the current browser.

I have:

function save_pocket($url){
    $enc = rawurlencode($url);
    $pocket = "http://getpocket.com/save/?url=";
    return $pocket.$enc;
}

save_pocket() is then called in <a href=".

But this returns either $url or $enc, I can't tell which. But the issue is it's not adding $pocket prefix.

Why?

OJFord
  • 10,522
  • 8
  • 64
  • 98
  • Where do you call `save_pocket`? – Explosion Pills Jul 07 '13 at 15:47
  • There is something borked somewhere else. As always in such situations: dump the intermediate result, so `$pocket.$enc` into a log file and check what it contains. Every other approach is just poking around in the mist. – arkascha Jul 07 '13 at 15:48
  • @ExplosionPills - href. – OJFord Jul 07 '13 at 15:50
  • @arkascha - sorry, I'm a bit new, can you elaborate on how? – OJFord Jul 07 '13 at 15:50
  • are you sure you are calling it like this `echo "Click";` ? – Mihai Vilcu Jul 07 '13 at 15:52
  • Just insert something like `syslog(LOG_DEBUG, "final url: ---$pocket.$enc---");` right before the return statement and make sure you have error loggin turned on in your php setup. Then monitor the log file using `tail -f /path/to/logfile` or similar and spot the output. – arkascha Jul 07 '13 at 15:53
  • @ionutvmi Thanks, but with that I get `$url` echoed on screen, and the link is only to `$pocket`. – OJFord Jul 07 '13 at 16:02

1 Answers1

1

Thanks for the responses, in the end it boiled down to me just being an idiot.

I was using a function which echo'd the url to pass urls into my function.

Swapped that for one that just presents url as a string, and it works like a champ.

Thanks again for tolerating my idiocy...

OJFord
  • 10,522
  • 8
  • 64
  • 98