Loading...

          java .net

          在GAE上簡單實現了一個淘寶客

          在網上無意搜到一個用Ext實現的淘寶客,恩 ,咱用GWT做一個車輪

          下了淘寶的 SDK for java就開干 參考API文檔按部就班

          在淘寶的沙箱里測試,很順利,乘勝前進,到正式環境下測試

          問題來了

          invalid signature

          網上搜了一通,有說時間戳不對,果不其然,GAE使用的是標準時間,整整差了8小時,遂在獲得的當前時間上加了8小時,OK

          invalid signature 可能的另一個原因是APP_KEY 或 APP_SERCET不正確,仔細檢查

           

          調用 taobao.item.get

           

          1 TaobaoClient client=new DefaultTaobaoClient(TaobaokeConstant.SANDBOX_URL, TaobaokeConstant.APP_KEY, TaobaokeConstant.APP_SERCET);
          2 ItemcatsGetRequest req=new ItemcatsGetRequest();
          3 java.util.Calendar c=java.util.Calendar.getInstance(TimeZone.getTimeZone("GMT+8"));
          4 c.add(Calendar.HOUR, 8);
          5 req.setTimestamp(c.getTime().getTime()) ;
          6 req.setParentCid(new Long(0));
          7 ItemcatsGetResponse response=client.execute(req);
          8 return response.getItemCats();

           

          調用 taobao.taobaoke.items.get

           
          1 TaobaoClient client=new DefaultTaobaoClient(TaobaokeConstant.SANDBOX_URL, TaobaokeConstant.APP_KEY,TaobaokeConstant.APP_SERCET);
          2 TaobaokeItemsGetRequest req=new TaobaokeItemsGetRequest();
          3 req.setFields("num_iid,title,nick,pic_url,price,click_url,commission,commission_rate,commission_num,commission_volume,shop_click_url,seller_credit_score,item_location,volume,taobaoke_cat_click_url,keyword_click_url");
          4 req.setCid(Long.parseLong(cid));
          5 req.setNick(TaobaokeConstant.NICK);
          6 req.setSort("commissionRate_desc");
          7 TaobaokeItemsGetResponse response=client.execute(req);
          8 return response.getTaobaokeItems();
           
          想用GAE JCache API 加入緩存以減輕壓力,但屢試不行,從緩存中取 的時候報錯
          沒找到原因
           
          改用自己寫的緩存,然后用App Engine Cron 服務管理緩存
           
          corn.xml
           
          1 <?xml version="1.0" encoding="UTF-8"?>
          2 <cronentries>
          3   <cron>
          4     <url>/cron/recache</url>
          5     <description>Repopulate the cache every 1 hours</description>
          6     <schedule>every 1 hours</schedule>
          7   </cron>
          8 </cronentries>

          posted on 2010-10-21 11:33 閱讀(751) 評論(0)  編輯  收藏 所屬分類: GAE

          公告

          希望有一天

          我能用鼠標雙擊我的錢包

          然后選中一張100元

          按住“ctrl+c”

          接著不停的“ctrl+v”

          嘻嘻~~~笑醒~~~



          導航

          <2010年10月>
          262728293012
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          統計

          常用鏈接

          留言簿(6)

          隨筆分類(102)

          隨筆檔案(398)

          文章分類

          文章檔案(10)

          有趣網絡

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 山东省| 承德县| 介休市| 建德市| 拜泉县| 石城县| 邛崃市| 泰和县| 拉萨市| 定远县| 黄石市| 阿坝县| 屯昌县| 茌平县| 马龙县| 永登县| 棋牌| 黄大仙区| 军事| 永昌县| 阜城县| 汤原县| 博兴县| 彩票| 北碚区| 邯郸市| 鄂州市| 河津市| 宣汉县| 隆化县| 全州县| 法库县| 郓城县| 凭祥市| 廊坊市| 容城县| 锡林郭勒盟| 苏尼特左旗| 洪江市| 澄城县| 舟曲县|