Twitter oauth with SSL using cURL in PHP -
i'm bit of beginner this. trying utilize curl perform request pull users tweets.
i've been able authenticate ok. cannot work out how data. i'm working localhost.
i've tried adding basic certificate not work.
do have purchase ssl certificate site? i've seen twitter feeds on other sites haven't purchased ssl certificates don't know how it?
i've seen in twitter documentation. file mentioned, 1 can purchase?
curl_setopt($connection, curlopt_ssl_verifypeer, true); curl_setopt($connection, curlopt_ssl_verifyhost, 2); curl_setopt($connection, curlopt_cainfo, "path:/ca-bundle.crt");
this curl code, worked before set curlopt_url
section in , got positive response server:
$url = "https://api.twitter.com/oauth2/token"; $headers = array( "post /oauth2/token http/1.1", "host: api.twitter.com", "user-agent: twitter app v.1", "authorization: basic ".$encoded."", "content-type: application/x-www-form-urlencoded;charset=utf-8" ); $ch = curl_init(); curl_setopt ($ch, curlopt_cainfo, "cacert.pem"); curl_setopt($ch, curlopt_url,$url); curl_setopt($ch, curlopt_httpheader, $headers); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_postfields, "grant_type=client_credentials"); curl_setopt($ch, curlopt_url, "http://twitter.com/statuses/user_timeline/".$username.".json?count=".$num_tweets); curl_setopt($ch, curlopt_returntransfer, 1); $header = curl_setopt($ch, curlopt_header, 1); curl_setopt($ch, curlopt_ssl_verifypeer, false); $output = curl_exec($ch); curl_close($ch);
edit: there problems code above, i'm aware i'm doing wrong not sure what. anyway, here original code had did work ok , got expected result server. next step request user's tweets timeline.
$ch = curl_init(); curl_setopt($ch, curlopt_url,$url); curl_setopt($ch, curlopt_httpheader, $headers); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_postfields, "grant_type=client_credentials"); $header = curl_setopt($ch, curlopt_header, 1); $result = curl_exec($ch); curl_close($ch); echo $result;
you may utilize curl_getinfo know what's going on.
you may post url of twitter documentation can have look.
$headers indicates host api.twitter.com curlopt_url uses twitter.com, typo ?
php ssl curl twitter
No comments:
Post a Comment