Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Twitter
#1
please help me with translating the following c# code to qm.

Macro
Code:
Copy      Help
[OperationContract]
public void SubmitUserStatus(string username, string tweet)
{
,// encode the username/password
,string user = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(username + ":" + password));
,// determine what we want to upload as a status
,byte[] bytes = System.Text.Encoding.ASCII.GetBytes("status=" + tweet);
,// connect with the update page
,HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://twitter.com/statuses/update.xml");
,// set the method to POST
,request.Method = "POST";
,// thanks to argodev for this recent change!
,request.ServicePoint.Expect100Continue = false;
,// set the authorisation levels
,request.Headers.Add("Authorization", "Basic " + user);
,request.ContentType = "application/x-www-form-urlencoded";
,// set the length of the content
,request.ContentLength = bytes.Length;
,// set up the stream
,Stream reqStream = request.GetRequestStream();
,// write to the stream
,reqStream.Write(bytes, 0, bytes.Length);
,// close the stream
,reqStream.Close();
}

i need a small dialog or toolbar where i can drag text to for sending short messages.


Attached Files Image(s)
   
pi
#2
i love the idea to have micro blogging tools.
with win T i will show my twigger client.
pi
#3
Function TwitterSubmitUserStatus
Code:
Copy      Help
;/
function $username $password $tweet

str user.encrypt(4 _s.from(username ":" password) "" 3)
str status.from("status=" tweet)
Http h.Connect("twitter.com")
h.Post("statuses/update.xml" status 0 _s.from("Authorization: Basic " user))
err+ end _error

not tested
#4
it works!

thanks a lot.
pi
#5
i use it now with F12.
twelve and twitter sounds similar.

currently i allow only text selection for it.
but it would be nice to have more control about selection.

its really funny to post short liners to twitter.
pi
#6
Using XP I can not get this to work.

QM does not return an error message, but no update seems to be sent to my twitter account.

Am I missing a step?

Thanks,
Jimmy Vig
#7
I don't get an error even when the password or username are incorrect.

I know the code runs because I put a debug output text at the end and that prints in QM.

Is there something more I need to know about this that I am missing or does it just not work on XP?

Thanks,
jimmy vig.
#8
When I tested on Vista, also did not work, and no error. Don't know why.
#9
i just made a test on xp and it works.
http://twitter.com/deskareas

Function twittertest
Trigger F12     Help - how to add the trigger to the macro
Code:
Copy      Help
spe -1
str txt.getsel

if txt.len>0
,
,tweet txt



Function tweet
Code:
Copy      Help
;/
function $text [$username] [$password]

username="myusername"
password="mypassword"


str user.encrypt(4 _s.from(username ":" password) "" 3)
str status.from("status=" text)
Http h.Connect("twitter.com")
h.Post("statuses/update.xml" status 0 _s.from("Authorization: Basic " user))
pi
#10
how do i add X-Twitter-Client to h.post?

X-Twitter-Client: QuickMacros
X-Twitter-Client-Url: Twitter
X-Twitter-Client-Version: 0.1

this does not work:
h.Post("statuses/update.xml" status 0 _s.from("Authorization: Basic " user " ,X-Twitter-Client:QuickMacros"))

example php curl code (pasted to qm to get colored code :mrgreen: )

$headers = array("X-Twitter-Client" => "Auto Tweet", "X-Twitter-
Client-Version" => "1.1", "X-Twitter-Client-URL" => "http://
feastofcrumbs.com/downloads/wp-plugins/auto-tweet/auto-tweet.xml");
$curl_handle = curl_init();
curl_setopt($curl_handle,CURLOPT_URL,"$twitter_rest");
curl_setopt($curl_handle,CURLOPT_HTTPHEADER,$headers);
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl_handle,CURLOPT_POST,1);
curl_setopt($curl_handle,CURLOPT_POSTFIELDS,"status=$content");
curl_setopt($curl_handle,CURLOPT_USERPWD,"$username:$password");
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
pi
#11
http headers must be separated by newlines, not commas, i'm sure you know
#12
I've put in exactly the example for this twitter post and cannot get it to work yet.

Is there a format that I need to put into the tweet text that tells twitter how to run it?

Thanks,
Jimmy Vig
#13
this function works for me

Function tweetTest
Code:
Copy      Help
;;/
function $text [$username] [$password]
text="viva la qm 2"
username="username"
password="password"


str user.encrypt(4 _s.from(username ":" password) "" 3)
_s.from("Authorization: Basic " user)
str header.format("%s[]X-Twitter-Client: QuickMacros" _s)


str status.from("status=" text)
Http h.Connect("twitter.com")

h.Post("statuses/update.xml" status 0 header)

out header
pi
#14
Copied it just like that...put in my username and password...nothing...no error, just the output.

Is there something I have to set in Twitter?

Thanks for sticking through so far with me on this Smile

Did you maybe install something that allows you to run this function properly that you haven't outlined well in this thread?

I've tested on a few different machines with no success.

Thanks,
Jimmy Vig
#15
I tried to use the codes for my twitter account, but it doesnt work.
Are there any parts missing? :oops:

How can i make a Tweet function that works by Dialog?
(inclusive saved login information)


And one more question:

How can i give a button a name stored in a variable?
(The variable should be saved (if password then encrypted) in a .txt or ini file for name and password)

Thanks in Advance for any help!
#16
Twitter now does not support Basic authentication. Need OAuth. Quite difficult to set up. Need to register application and learn much.

http://dev.twitter.com/doc
#17
Ok, i see that its easier to log in manually. :mrgreen:


Forum Jump:


Users browsing this thread: 1 Guest(s)