
Asi,<br><br>I did figure it out back in February of this year and have done a lot of other programming since then, so I don't recall specifically what was wrong, so I am just going to include the working program below:<br><br><?php<br><br>//Libraries used for accessing YMail api's.<br>require_once 'OAuth.php';<br>require_once 'JsonRpcClient.inc';<br><br>//Endpoint for Yahoo mail WSDL<br>$endPoint = 'http://mail.yahooapis.com/ws/mail/v1.1';<br><br>//OAuth Endpoint<br>$OAuthEndPoint = 'https://api.login.yahoo.com/oauth/v2';<br><br>//You can get these keys from YDN.<br>$OAuthConsumerKey = '';<br>$OAuthConsumerSecret = '';<br><br>// see http://developer.yahoo.com/oauth/guide/oauth-auth-flow.html<br>$signature = new OAuthSignatureMethod_HMAC_SHA1();<br><br>// 1) Get Request Token<br>$request = new OAuthRequest('GET', "$OAuthEndPoint/get_request_token", array(<br> 'oauth_consumer_key'=>$OAuthConsumerKey,<br> 'oauth_signature_method'=>'PLAINTEXT',<br> 'oauth_version'=>'1.0',<br> 'oauth_timestamp'=>time(), <br> 'oauth_nonce'=>mt_rand(),<br> 'oauth_callback'=>'oob'));<br>$url = $request->to_url()."&oauth_signature=$OAuthConsumerSecret%26";<br><br>$ch = curl_init();<br>curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );<br>curl_setopt( $ch, CURLOPT_URL, $url );<br>$resp = curl_exec( $ch );<br>curl_close($ch);<br>parse_str($resp,$tokens);<br>$oauth_token = $tokens['oauth_token'];<br>$oauth_token_secret = $tokens['oauth_token_secret'];<br><br>if (!$oauth_token || !$oauth_token_secret) {<br> throw new Exception($resp); <br>}<br><br>// 2) Get User Auth<br>echo " Open this Url in your browser ->> $OAuthEndPoint/request_auth?oauth_token=$oauth_token \n";<br>echo " This should be provided to end users of your application.End users should provide their <br>'Username' and 'Password' and sign-in which means they authorize your app. On successful login the end users will see a code in the page \n";<br>echo " This code is the oauth_token which Yahoo returns to your app \n";<br>echo " Enter the code here: ";<br>$oauth_verifier = trim(fgets(STDIN));<br><br>// 3) Get Access Token<br>$request = new OAuthRequest('GET', "$OAuthEndPoint/get_token", array(<br> 'oauth_consumer_key'=>$OAuthConsumerKey, <br> 'oauth_signature_method'=>'PLAINTEXT',<br> 'oauth_version'=>'1.0',<br> 'oauth_verifier'=>$oauth_verifier,<br> 'oauth_token'=>$oauth_token, <br> 'oauth_timestamp'=>time(), <br> 'oauth_nonce'=>mt_rand(), <br> ));<br>$url = $request->to_url()."&oauth_signature=$OAuthConsumerSecret%26$oauth_token_secret";<br><br>$ch = curl_init();<br>curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );<br>curl_setopt( $ch, CURLOPT_URL, $url );<br>$resp = curl_exec( $ch );<br>curl_close($ch);<br><br>parse_str($resp);<br>if (!$oauth_token || !$oauth_token_secret) {<br> throw new Exception($resp); <br>}<br><br>$mid = ''; //i.e., 1_68195_AMvJjkQAAJJjTQgZpgDJg1E%2FJsk<br><br>$request = new OAuthRequest('GET', "http://mail.yahooapis.com/ya/download/?mid=$mid&fid=Inbox&pid=2&clean=0&inline=0", array(<br> 'oauth_consumer_key'=>$OAuthConsumerKey,<br> 'oauth_nonce'=>mt_rand(),<br> 'oauth_signature_method'=>'HMAC-SHA1',<br> 'oauth_timestamp'=>time(),<br> 'oauth_token'=>$oauth_token,<br> 'oauth_version'=>'1.0',<br> 'oauth_callback'=>'oob'));<br>$request->sign_request($signature, new OAuthConsumer('', $OAuthConsumerSecret), new OAuthToken('', $oauth_token_secret));<br>$oauthURL = $request->to_url();<br><br>$ch = curl_init(); <br>curl_setopt($ch, CURLOPT_URL, $oauthURL);<br>curl_setopt($ch, CURLOPT_HEADER, true);<br>curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);<br>$header = curl_exec($ch);<br>if ( curl_errno($ch)) {<br> $code = 0;<br>}<br>else {<br>$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);<br>}<br><br>echo "\n\n".$header; //header contains the attachment--simple way of getting attachment<br><br>$file = ''; //i.e., file.pdf<br>$fh = fopen($file, 'w') or die("can't open file");<br>fwrite($fh, $header);<br>fclose($fh);<br><br>curl_close($ch);<br><br>exit(0);<br><br><br><br><div class="quote"><div class="quotetop">QUOTE<cite>(Asi Shmaiser @ 24 Sep 2011 9:21 AM)</cite></div><blockquote class="quotemain">great to here, so maybe you can help me out :)<br>I didn't understand what's the solution - <br><br>1. did u use an OAuth Authorization header or sent all the oauth parameters in the url?<br>2. should the signature contains the regular params (mid, fid... ) or just the basic url + oauth parameters?<br><br>this is my request:<br><br>http://mail.yahooapis.com/ya/download?clean=0&fid=Inbox&inline=0&mid=1_22_1_4931_0_AIHTimIAAAG0Tmsv5AzWR1FOqEA&pid=2&oauth_consumer_key=..............&oauth_nonce=8016381357093189350&oauth_signature=EcZSH5%2B6ny6U%2BHWAmLgWG9RXQlk%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1316881005&oauth_token=A%3DkOSQRMrSmwPrWniqY02.4qxYoKKD61EIL19M9uDuBvRBbtxCiRVx7jJum3cV6ebWNdM0zDF7sU2ezKPa2Y6cT9ZJIlazRBkxhasb_l1n3I_DmRY48drpYDMB2g4IEPZF355iOQ7FGIJaxTCT6E1nJSlmgqbx7zmrJHOe43qiyhWWSVNOLzVWUjAWdTUYN4jJ3hodR1o.55sbHlBIdq.L.lmR5D4VS7tBbqg7mt9t9gclib3s17JNwmvX.8s7OJRQ5fZMBbxWaTKytcnl_DaNlUAljYX6yEbaxkTmOMB7fNrEFeexklpNfAlTy8.rmVAddLh8J0vI12hNYYuuPRRXzMrSgDoDV27x1AsiMDt1fJWj43Sd3NPvmmwCCXwxwCXn0ad_1h.YJPUqyJxEwxuYFK85XdrHpfeULgwth6Fukh7PaC5v9jvQOQR9p_wDIHJKuBFcmZkjlp7h1ID0Y08WbdMotaX1qMkbPmMvPhX7AV8VfasFxj3vo3.MVmc6ndWLPAXX0ep6EkNrpBZadI6tK_5a213QvRPlZcneCcdXWJWD5BpyDrMXdyVdMMC5bB6jQ0jBEN9GmxbMuvt9Xo0N8IlKLJII7jfmZZpPjC8V8HklHbpOOQaDsGU1muDdNAgPKi6qp53ZH5.TuUd7X3C_51pvPC0uopJaAs7SE9XBEVjCNeEZ9jkbJuRoUgTkoBcZTNa6PJXH7j9q5NZ4KTiL2z2Kjq_3fPrO3U0plPn7cF.T0UmqLwhtZisL1HouwQ--&oauth_version=1.0<br><br>I keep getting 404 Not Found for that request. <br>If I drop the mid,fid.. params I get "500 unable_to_get_message_info_or_part".<br><br>other calls to the Yahoo mail web services are working just fine with the oauth mechanism... <br>any ideas?<br><br>thank a lot,<br>Asi.<br><br><div class="quote "><div class="quotetop ">QUOTE<cite>(Obiora @ 23 Sep 2011 5:09 PM)</cite><blockquote class="quotemain">Yes, I did resolve the problem.<br><br>Thank you for checking in with me.<br><br><div class="quote "><div class="quotetop ">QUOTE<cite>(Asi Shmaiser @ 23 Sep 2011 2:10 AM)</cite><blockquote class="quotemain">Hi Obiora,<br>did u manage to solve the download problem?<br><br><div class="quote "><div class="quotetop ">QUOTE<cite>(Obiora @ 4 Jan 2011 5:06 PM)</cite><blockquote class="quotemain">Hello, I am having issues with downloading an attachment via the API for Yahoo! Mail.<br><br>I have used several different Oauth libraries and have recently tested code (http://nullinfo.wordpress.com/oauth-yahoo/) for CallContact, which does work.<br><br>I am using the data generated from CallContact to download an attachment and the sent header and response are below:<br><br>GET /ya/download?mid=1_14882_AMvJjkQAAJJjTQgZpgDJg1E%252FJsk&fid=Inbox&pid=2&clean=0&inline=0 HTTP/1.1<br>Host: mail.yahooapis.com<br>Accept: */*<br>Authorization: OAuth realm="yahooapis.com",oauth_version="1.0",oauth_nonce="1890108292",oauth_timestamp="1294189375",oauth_consumer_key="...",oauth_token="A%3D7haljcPKlDiLigYC7eZ6af8lD_yXf_lh2fxl.SnsPPmh.N4FR8LKOWrEjC7h1qC4KOhwBfP8Ynz190<br>ecUDM5f6rsYUSsn1iUUresRql6Uqlbn2x3BZHZkbCJWPuBNxT9vYYHKUWdKJs_nGeG.AwXFs9YmB2sPuF<br>9Lrqf1Jq0qdKZysw6EY2SteTrJGVG3eCT95qe2JU6YhQAOzuh_.3A3uFivT3srxeeqpDnjtTATlG3cHyX<br>.dhcGoVv45qe6TJHsHWvehW7nmjmmi0LpKrZpDJz_4JneNrU0QynQnmIwXmsTcaAWAgs_sKQrsh0121mg<br>T8gDpjKfkeqX6ER.KdxmFzzajphBvpLUmaIKXj4HEoiDIIKMElPTXJKZ5J9ZHlWTDqykkqCUoQvbTVv67<br>J1FEq_nshkJLcRakdy2njPxVYP.KhXBlok7CU.0JHbGVIhPfffNbUkSGWHVXhf1oXGdn9PrSHZ05EglRe<br>QX.YbWACc6yR4D0BtROlqgJWNkhuE1hpg_TfHiDZNxJ7Qch2A6geMwn8x_E3kZgn75PkHqEFbgGJpd9_5<br>pkL1ry4ag5nyNfCyqQGDvVfNOk3511aelS82hH5NG.qVRT8KtlOHNKm3IR3lmeoeqSJXBbhbFLl49Dj2f<br>QyIMmn3peT340aWOPhdFWd1yhyEHa95_zMB2Qq0KJFdKp9sxVShRr_0YDQxhDdKHx8sBU21hgzkXHHmTk<br>ji9AfSlZh1giYYz2BBBr3vWMVpZY0RJp4X67JApXBju1IeB.u8Xvbd.q7.aR8-",oauth_signature_method="HMAC-SHA1",oauth_signature="lO%2FnmSh7frpRHi%2BV8S5EmieH2Tc%3D"<br><br>Response headers:<br><br>HTTP/1.1 404 Not Found<br>Date: Wed, 05 Jan 2011 01:02:40 GMT<br>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"<br>Vary: Accept-Encoding<br>Content-Type: text/html; charset=iso-8859-1<br>Age: 0<br>Transfer-Encoding: chunked<br>Connection: keep-alive<br>Server: YTS/1.17.23<br><br>The mid has been encoded and the URL is correct and is based on the documentation. Is there something that I am missing that the documentation does not cover??<br><br>Thank you.<br><br><br>Sincerely,<br>Obiora</blockquote></div></div></blockquote></div></div></blockquote></div></div></blockquote></div>