shell_exec escaping quotes in php for Twitter API
- by yc10
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?