0

Error -1005 Invalid Argument Error - yahoo IM send_message - http://github.com/yahoo/messenger-sdk

Hello,

I have tried http://github.com/yahoo/messenger-sdk ; everything is fine until trying to send sms using the function send_message($user, $message). It returns:
"error":{"code":-1005,"detail":"Invalid Argument Error","description":"Invalid Argument Error"}

public function send_message($user, $message)
    {
        //prepare url
        $url = $this->URL_YM_MESSAGE;
        $url = 'http://developer.messenger.yahooapis.com/v1/message/yahoo/{{USER}}';          
        $url .= '?oauth_consumer_key='. $this->_config['consumer_key'];   
       
        $url .= '&realm=yahooapis.com'  ;
           
        $url .= '&oauth_nonce='. uniqid(rand());
        $url .= '&oauth_signature='. $this->_config['secret_key']. '%26'. $this->_token['access']['oauth_token_secret'];
        $url .= '&oauth_signature_method=PLAINTEXT';
        $url .= '&oauth_timestamp='. time();
        $url .= '&oauth_token='. $this->_token['access']['oauth_token'];
        $url .= '&oauth_version=1.0';   
        $url .= '&sid='. $this->_ym['signon']['sessionId'];
        $url = str_replace('{{USER}}', $user, $url);
       
        //additional header
        $header[] = 'Content-type: application/json; charset=utf-8';
        $postdata = '{"message" : '. $message. '}';      
              
        $rs = $this->curl($url, 'post', $header, $postdata);
       
         
       
        return true;
    }

It's just the function found in the package downloaded at http://github.com/yahoo/messenger-sdk. As shown at http://developer.yahoo.com/messenger/guide/ch05s06.html, looks like the 'realm' parameter is missing from the original function "send_message"; so I have added it. But the result still shows "Invalid Argument Error"...

Below is the information which was sent to yahoo server (in the form of: $url, 'post', $header, $postdata):

http://developer.messenger.yahooapis.com/v1/message/yahoo/a_tim?oauth_consumer_key=dj0yJmk9...&realm=yahooapis.com&oauth_nonce=6078207...&oauth_signature=5b7b...036c%264e0a...6aa&oauth_signature_method=PLAINTEXT&oauth_timestamp=1344417169&oauth_token=A%3D5hV.HX....8.o_99y_zk&oauth_version=1.0&sid=KbJa...T6A5, 'post', Array, {"message" : test ccc cccc}

Could somebody please show me how to fix it?
Thank you very much.

by
  • As
  • Aug 8, 2012
2 Replies
  • Hey OP, this actually isn't a Yahoo error.

    The PHP SDK has a typo on line 242, $postdata = '{"message" : '. $message. '}';

    Just enclose the message variable in double quotes and cURL shouldn't throw argument errors. Hopefully that will help anyone else who comes to this issue in the future.
    0
  • Ryan suggestion should work.

    If you notice in client.php, the message being sent in the send_message()  call is json_encode-ed.
    This ensures that you pass in a valid json string.
    $engine->send_message($val['sender'], json_encode($out));
    0

Recent Posts

in Messenger IM SDK