mIRC Home    About    Download    Register    News    Help

Print Thread
#251774 02/03/15 10:36 PM
Joined: Nov 2014
Posts: 3
W
Woo991 Offline OP
Self-satisified door
OP Offline
Self-satisified door
W
Joined: Nov 2014
Posts: 3
im trying to make a latest tweet bot that uses twitters api, with lots of reading and searching i got up to this point.
Code:
on *:TEXT:!twittertest*:#woo991: {
  set %target $iif($2,$2,$mid(#,2-))
  set %channel #
  tweet 
}

alias tweet {
  sockclose tweet
  sockopen tweet api.twitter.com 80
}

on *:sockopen:tweet:{
  if ($sockerr) { sockclose $sockname | halt }
  sockwrite -n $sockname GET /1.1/statuses/user_timeline.json?exclude_replies=true&include_rts=false&screen_name=summit1g HTTP/1.1
  sockwrite -n $sockname Authorization: OAuth oauth_consumer_key="DC0sePOBbQ8bYdC8r4Smg",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1425333220",oauth_nonce="1736710918",oauth_version="1.0",oauth_token="2687440547-a2rUEIqiuySXVL2ydFUySCAhuZRaJdvGRZRJKrX",oauth_signature="uq2xqLkag0v1Gd2PJBfTpNQfbR0%3D"
  sockwrite -n $sockname Host:api.twitter.com
  sockwrite -n $sockname X-Target-URI: https://api.twitter.com
  sockwrite -n $sockname Connection: Keep-Alive
  sockwrite -n $sockname $crlf
}

on *:sockread:tweet:{
  if ($sockerr) { sockclose $sockname | halt }
  var %data
  sockread %data
  if (text iswm %data) {
    msg #woo991 %data $2-
  }
  msg $chan sockread %data
}

on *:sockclose:tweet:{ 
  unset %channel
  unset %target
}


the code is based on many other users but i cannot get it to work, i get this in return when its ran.

Quote:

[05:19] -> *sockread* HTTP/1.1 403 Forbidden
-
[05:19] -> *sockread* content-length: 52
-
[05:19] -> *sockread* content-type: application/json;charset=utf-8
-
[05:19] -> *sockread* date: Mon, 02 Mar 2015 22:19:57 UTC
-
[05:19] -> *sockread* server: tsa_b
-
[05:19] -> *sockread* set-cookie: guest_id=v1%3A142533479782658557; Domain=.twitter.com; Path=/; Expires=Wed, 01-Mar-2017 22:19:57 UTC
-
[05:19] -> *sockread* x-connection-hash: 03f7fa03b5160fc6a49b457faebd99a2
-
[05:19] -> *sockread* x-response-time: 5


http://imgur.com/Q70uOyl (picture to api page)

i got oath info(and everything else) from that on this link
i was thinking the return would be the responce side would be what i recived when executed. any clue how to get this stuff to work and get an actual responce?

Last edited by Woo991; 02/03/15 10:37 PM.
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Please read through this to realize it's not as trivial as copy/pasting requests sent by another application: https://dev.twitter.com/oauth/overview/authorizing-requests

This seems to be a script worth looking at: http://hawkee.com/snippet/7945/

Joined: Jan 2015
Posts: 40
J
Ameglian cow
Offline
Ameglian cow
J
Joined: Jan 2015
Posts: 40
Interesting.

"Connection Actively Refused --> HTTP/1.1 403 Forbidden"

Maybe things have changed since the script was last updated. It does not appear to work right now with my own keys in it.


Link Copied to Clipboard