0

SEND MESSAGE - NEED HELP PLEASE

How can I send messages from my appliation to yahoo messenger. I have added the user of the application on yahoo messenger. When I try to send message, using the function I don;t get anything

public function send_message($user, $message) ( i presume user and message is the user name on yahoo messenger, and not the user of the application)


need help, please
this is the code:

Random rand = new Random();
int randNo = rand.Next(1000, 9999);

string uri = URL_YM_MESSAGE +
"?oauth_consumer_key=" + CONSUMER_KEY +
"&oauth_nonce=" + randNo.ToString() +
"&oauth_signature=" + SECRET_KEY + "%26" + OAUTH_TOKEN_SECRET +
"&oauth_signature_method=PLAINTEXT" +
"&oauth_timestamp=" + DateTime.Now +
"&oauth_token=" + OAUTH_TOKEN +
"&oauth_version=1.0" +
"&sid=" + SESSION_ID;

uri = uri.Replace("{{USER}}", usernam); -< the user name on yahoo messenger and not the one on c# application

string postData = "{ \"message\" :" + message+ "}";
HttpWebRequest messageRequest = WebRequest.Create(uri) as HttpWebRequest;

messageRequest.Method = "POST";
messageRequest.ContentType = "application/json;charset=utf-8"

messageRequest.ContentLength = postData.Length;

Stream dataStream = messageRequest.GetRequestStream();
UTF8Encoding encoder = new UTF8Encoding();
byte[] bytes = encoder.GetBytes(postData);
dataStream.Write(bytes, 0, bytes.Length);
//dataStream.Flush();

by
3 Replies
  • Hello,

    I think you are not sending post data in correct format.Try this

    string postdata = "{\"message\":\"" + message + "\"}";

    if it not works then let me know.


    Thanks



    QUOTE (Message Sph @ Feb 17 2011, 02:03 AM) <{POST_SNAPBACK}>
    How can I send messages from my appliation to yahoo messenger. I have added the user of the application on yahoo messenger. When I try to send message, using the function I don;t get anything

    public function send_message($user, $message) ( i presume user and message is the user name on yahoo messenger, and not the user of the application)


    need help, please
    this is the code:

    Random rand = new Random();
    int randNo = rand.Next(1000, 9999);

    string uri = URL_YM_MESSAGE +
    "?oauth_consumer_key=" + CONSUMER_KEY +
    "&oauth_nonce=" + randNo.ToString() +
    "&oauth_signature=" + SECRET_KEY + "%26" + OAUTH_TOKEN_SECRET +
    "&oauth_signature_method=PLAINTEXT" +
    "&oauth_timestamp=" + DateTime.Now +
    "&oauth_token=" + OAUTH_TOKEN +
    "&oauth_version=1.0" +
    "&sid=" + SESSION_ID;

    uri = uri.Replace("{{USER}}", usernam); -< the user name on yahoo messenger and not the one on c# application

    string postData = "{ \"message\" :" + message+ "}";
    HttpWebRequest messageRequest = WebRequest.Create(uri) as HttpWebRequest;

    messageRequest.Method = "POST";
    messageRequest.ContentType = "application/json;charset=utf-8"

    messageRequest.ContentLength = postData.Length;

    Stream dataStream = messageRequest.GetRequestStream();
    UTF8Encoding encoder = new UTF8Encoding();
    byte[] bytes = encoder.GetBytes(postData);
    dataStream.Write(bytes, 0, bytes.Length);
    //dataStream.Flush();
    0
  • I succeded, thanks. Can you please tell me how ca I send and receive messages instantly?
    ... or I can appeal both of them by using a recursion function?
    0
  • thats very nice and cool

    [size="5"][/size]


    QUOTE (Message Sph @ Feb 17 2011, 02:03 AM) <{POST_SNAPBACK}>
    How can I send messages from my appliation to yahoo messenger. I have added the user of the application on yahoo messenger. When I try to send message, using the function I don;t get anything

    public function send_message($user, $message) ( i presume user and message is the user name on yahoo messenger, and not the user of the application)


    need help, please
    this is the code:

    Random rand = new Random();
    int randNo = rand.Next(1000, 9999);

    string uri = URL_YM_MESSAGE +
    "?oauth_consumer_key=" + CONSUMER_KEY +
    "&oauth_nonce=" + randNo.ToString() +
    "&oauth_signature=" + SECRET_KEY + "%26" + OAUTH_TOKEN_SECRET +
    "&oauth_signature_method=PLAINTEXT" +
    "&oauth_timestamp=" + DateTime.Now +
    "&oauth_token=" + OAUTH_TOKEN +
    "&oauth_version=1.0" +
    "&sid=" + SESSION_ID;

    uri = uri.Replace("{{USER}}", usernam); -< the user name on yahoo messenger and not the one on c# application

    string postData = "{ \"message\" :" + message+ "}";
    HttpWebRequest messageRequest = WebRequest.Create(uri) as HttpWebRequest;

    messageRequest.Method = "POST";
    messageRequest.ContentType = "application/json;charset=utf-8"

    messageRequest.ContentLength = postData.Length;

    Stream dataStream = messageRequest.GetRequestStream();
    UTF8Encoding encoder = new UTF8Encoding();
    byte[] bytes = encoder.GetBytes(postData);
    dataStream.Write(bytes, 0, bytes.Length);
    //dataStream.Flush();
    0

Recent Posts

in Messenger IM SDK