shell_exec escaping quotes in php for Twitter API
Posted
by yc10
on Stack Overflow
See other posts from Stack Overflow
or by yc10
Published on 2010-04-01T17:51:58Z
Indexed on
2010/04/01
17:53 UTC
Read the original article
Hit count: 691
I'm (lazily) using shell_exec() to execute a Twitter API Call.
shell_exec('curl -u user:password -d "id=3191321" http://api.twitter.com/1/twitterapi/twitterlist/members.xml');
That works fine when I authenticate correctly and put in a number for the id.
But when I try to put in a variable ($id), it screws up.
$addtolist = shell_exec('curl -u pxlist:Weekend1 -d "id='.$id.'" http://twitter.com/username/twitterlist/members.xml');
I tried flipping the quote types
$addtolist = shell_exec("curl -u pxlist:Weekend1 -d 'id=$id' http://twitter.com/username/twitterlist/members.xml");
I tried using double quotes and escaping them
$addtolist = shell_exec("curl -u pxlist:Weekend1 -d \"id=$id\" http://twitter.com/username/twitterlist/members.xml");
None of them worked.
What am I doing wrong?
© Stack Overflow or respective owner