0

desktop application with yahoo Mail API

hello,
i been told to open this thread here: oauth forums

i have a desktop application that will fetch user email from his yahoo account.
i wrote this POC but i keep getting 500 error.

CODE
function getYahooEmails(){
var aParams = [{'fid':'inbox','startInfo':0,'numInfo':10}];
var oRequest = {'method':'ListMessages','params': aParams};
var sRequest = json_encode(oRequest); //i took json_encode from here: http://phpjs.org/functions/json_encode:457
var sUrl = 'http://mail.yahooapis.com/ws/mail/v1.1/jsonrpc';
var sHeader = 'OAuth oauth_nonce="f65670481f2282ddc82607e148de374a",oauth_timestamp="1272050828",oauth_version="1.0",oauth_signature_method="HMAC-SHA1",oauth_consumer_key="MYKEY",oauth_token="TOKEN",oauth_signature="SIG"'; //this value is from my web page application
var oAjax = new XMLHttpRequest();
oAjax.open("POST",sUrl,true);
oAjax.setRequestHeader("Content-Type", "application/json");
oAjax.setRequestHeader("Accept", "application/json");
oAjax.setRequestHeader("Authorization", sHeader);
oAjax.setRequestHeader("Connection", "close");
oAjax.onreadystatechange=function(){
if(oAjax.readyState != 4) return;
if(oAjax.status != 200) return;
document.getElementById('result').innerText = oAjax.responseText;
}
oAjax.send(sRequest);
}

i use fiddler
this is the request header:
CODE
POST /ws/mail/v1.1/jsonrpc HTTP/1.1
Accept: application/json
Accept-Language: he
Pragma: no-cache
Authorization: OAuth oauth_nonce="f65670481f2282ddc82607e148de374a",oauth_timestamp="1272050828",oauth_version="1.0",oauth_signature_method="HMAC-SHA1",oauth_consumer_key="MYKEY",oauth_token="TOKEN",oauth_signature="SIG"
Content-Type: application/json
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; OfficeLiveConnector.1.4; OfficeLivePatch.1.3)
Host: mail.yahooapis.com
Content-Length: 117
Connection: Keep-Alive


this is the response:
CODE
HTTP/1.1 500 Internal Server Error 88
Date: Fri, 23 Apr 2010 19:27:44 GMT
P3P: policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"
Vary: Accept-Encoding
Content-Type: application/json
Cache-Control: private
Age: 0
Transfer-Encoding: chunked
Connection: keep-alive
Server: YTS/1.17.23

{"result":null,"error":{"code":"Client.FolderIdDoesntExist","message":"Folder ID doesn't exist.","detail":null}


note: i have no cross domain issue with ajax as this is from "localhost" to yahoo servers.

what is the problem?
do you guys have a working ajax/jsonp snippet that is working?

thanks
Elad

by
1 Reply
  • Hi,

    Please give fid as Inbox and not inbox. aParams should be like var aParams= [{'fid':'Inbox','startInfo':0,'numInfo':10}];

    --R


    QUOTE (icqdev @ Apr 24 2010, 03:39 AM) <{POST_SNAPBACK}>
    hello,
    i been told to open this thread here: oauth forums

    i have a desktop application that will fetch user email from his yahoo account.
    i wrote this POC but i keep getting 500 error.

    CODE
    function getYahooEmails(){
    var aParams = [{'fid':'inbox','startInfo':0,'numInfo':10}];
    var oRequest = {'method':'ListMessages','params': aParams};
    var sRequest = json_encode(oRequest); //i took json_encode from here: http://phpjs.org/functions/json_encode:457
    var sUrl = 'http://mail.yahooapis.com/ws/mail/v1.1/jsonrpc';
    var sHeader = 'OAuth oauth_nonce="f65670481f2282ddc82607e148de374a",oauth_timestamp="1272050828",oauth_version="1.0",oauth_signature_method="HMAC-SHA1",oauth_consumer_key="MYKEY",oauth_token="TOKEN",oauth_signature="SIG"'; //this value is from my web page application
    var oAjax = new XMLHttpRequest();
    oAjax.open("POST",sUrl,true);
    oAjax.setRequestHeader("Content-Type", "application/json");
    oAjax.setRequestHeader("Accept", "application/json");
    oAjax.setRequestHeader("Authorization", sHeader);
    oAjax.setRequestHeader("Connection", "close");
    oAjax.onreadystatechange=function(){
    if(oAjax.readyState != 4) return;
    if(oAjax.status != 200) return;
    document.getElementById('result').innerText = oAjax.responseText;
    }
    oAjax.send(sRequest);
    }

    i use fiddler
    this is the request header:
    CODE
    POST /ws/mail/v1.1/jsonrpc HTTP/1.1
    Accept: application/json
    Accept-Language: he
    Pragma: no-cache
    Authorization: OAuth oauth_nonce="f65670481f2282ddc82607e148de374a",oauth_timestamp="1272050828",oauth_version="1.0",oauth_signature_method="HMAC-SHA1",oauth_consumer_key="MYKEY",oauth_token="TOKEN",oauth_signature="SIG"
    Content-Type: application/json
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; OfficeLiveConnector.1.4; OfficeLivePatch.1.3)
    Host: mail.yahooapis.com
    Content-Length: 117
    Connection: Keep-Alive


    this is the response:
    CODE
    HTTP/1.1 500 Internal Server Error 88
    Date: Fri, 23 Apr 2010 19:27:44 GMT
    P3P: policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"
    Vary: Accept-Encoding
    Content-Type: application/json
    Cache-Control: private
    Age: 0
    Transfer-Encoding: chunked
    Connection: keep-alive
    Server: YTS/1.17.23

    {"result":null,"error":{"code":"Client.FolderIdDoesntExist","message":"Folder ID doesn't exist.","detail":null}


    note: i have no cross domain issue with ajax as this is from "localhost" to yahoo servers.

    what is the problem?
    do you guys have a working ajax/jsonp snippet that is working?

    thanks
    Elad
    0

Recent Posts

in Yahoo! Mail Web Services API