curl_exec returns 1 for oauth2 API 1.1


#1

I followed the instructions in the manual, and I don’t get any errors, but the php cURL function isn’t returning JSON. It just returns 1. Any ideas?

Thanks.
Here is the code I am using:

 $consumerKey = urlencode('consumerKey');
    $consumerSecret = urlencode('consumerSecret');
    $consumerConcatination = $consumerKey . ':' . $consumerSecret;
    $encoded = base64_encode($consumerConcatination);
    $array['grant_type'] = 'client_credentials';
    $ch = curl_init("https://api.twitter.com/oauth2/token");
    curl_setopt($ch, CURLOPT_USERAGENT, 'TweetWordCount v0.1');
    curl_setopt($ch, CURLOPT_POSTFIELDS, $array);
    curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Basic $encoded Content-Type: application/x-www-form-urlencoded;charset=UTF-8",'Content-Length:500'));
    curl_exec($ch);
    curl_close($ch);


#2

Figured it out.


#3

So, I did this and I have no idea how to put the string, that is printing out to the screen, into a variable. I can decode the JSON. I am just not sure how to collect the returned data.