I hope you can help me about this issue.
I’m trying to get followers Ids list (just to mention one) from Twitter using APEX code (salesforce).
I was using in the past Oauth APIs and those were working fine.
After I started approaching to the 1.1 APIs every kind of request is receiveing the 32/401 response, it should mean that I’m sending out a wrong Oauth header content.
So I decided to make a test:
I used https://dev.twitter.com/rest/tools/console in order to generate a good request in terms of Oauth header details, so starting from the consol everything goes fine;
I then used the same Oauth header (copy/paste) making a try from CURL (windows shell) and it is going fine as well, so also in this case I’m receiving the result with the full list of Followers/ids,
using the same oauth header (authorization) is not working from APEX.
I have been searching for a while googling this issue but the answer is still not positive, just to add a bit see the code below:
**//create http instance** **Http http = new Http();** **//create request instance** **HttpRequest req = new HttpRequest();** **//set request details** **req.setMethod('GET');** **req.setEndpoint('https://api.twitter.com/1.1/followers/ids.json?cursor=-1&screen_name=myscreenname&user_id=myuserid');** **req.setBody('');** **//prepare the header** **req.setHeader('X-Target-URI', 'https://api.twitter.com');** **req.setHeader('Authorization', 'OAuth oauth_consumer_key="myconsumerkey",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1431356060",oauth_nonce="randomnonce",oauth_version="1.0",oauth_token="mytoken",oauth_signature="mysignature"');** **req.setHeader('Host', 'api.twitter.com');** **req.setHeader('Connection', 'Keep-Alive');** **HTTPResponse res = http.send(req);** **String resBody = res.getBody();** **System.debug('getBody: ' + resBody);**
Is there anyone that can help me with this ?