zoukankan      html  css  js  c++  java
  • Delphi XE7 用indy开发微信公众平台所有功能,可刷阅读,可刷赞,可加推广(除微支付)

    关注作者的微信公众平台,测试效果

    包含微信公众平台的所有功能(除微支付)

    示例代码:(如需要全部代码,请加作者微信:Leedege

    function UpNews(Num: Integer; AccessToken: String): String;
    var
      J: TJSONObject;
      N: array of TJSONObject;
      Url: String;
      temp: String;
      i: Integer;
      readnum, ad: TStringList;
    begin
      J := TJSONObject.Create;
      readnum := TStringList.Create;
      ad := TStringList.Create;
      ad.LoadFromFile('ad.txt');
      SetLength(N, Num);
      try
        J.AddPair('articles', TJSONArray.Create);
        with J.GetValue('articles') as TJSONArray do
          for i := 0 to Num - 1 do
          begin
            temp := TNewsMsg(NewsList.Items[i]^).Content;
    
            if TNewsMsg(NewsList.Items[i]^).AddTop then
              temp := TNewsMsg(NewsList.Items[i]^).adTop + temp;
    
            readnum.LoadFromFile('readnum.txt');
            if TNewsMsg(NewsList.Items[i]^).RefreshReadNum then
              readnum.Text := StringReplace(readnum.Text, 'readNum',
                TNewsMsg(NewsList.Items[i]^).readnum, [rfReplaceAll]);
    
            if TNewsMsg(NewsList.Items[i]^).RefreshLikeNum then
              readnum.Text := StringReplace(readnum.Text, 'likeNum">',
                TNewsMsg(NewsList.Items[i]^).LikeNum, [rfReplaceAll]);
    
            if TNewsMsg(NewsList.Items[i]^).SourceURL <> '' then
              readnum.Text := StringReplace(readnum.Text, 'href=""',
                Format('href="%s"', [TNewsMsg(NewsList.Items[i]^).SourceURL]),
                [rfReplaceAll]);
    
            temp := temp + readnum.Text;
            readnum.Clear;
            if TNewsMsg(NewsList.Items[i]^).AddBottom then
              temp := temp + ad.Text + TNewsMsg(NewsList.Items[i]^).adBottom;
    
            N[i] := TJSONObject.Create;
            N[i].AddPair('thumb_media_id', UpMedia(AccessToken, 'image',
              TNewsMsg(NewsList.Items[i]^).CoverFile));
            N[i].AddPair('author', TNewsMsg(NewsList.Items[i]^).Author);
            N[i].AddPair('title', TNewsMsg(NewsList.Items[i]^).Title);
            N[i].AddPair('content_source_url', '');
            N[i].AddPair('content', temp);
            N[i].AddPair('digest', TNewsMsg(NewsList.Items[i]^).Digest);
            N[i].AddPair('show_cover_pic', TNewsMsg(NewsList.Items[i]^)
              .ShowCover.ToString);
            Add(N[i]);
            temp := '';
          end;
        Url := Format(UpNewsUrl, [AccessToken]);
        temp := PostMethod(Url, UTF8Encode(J.ToString), 1);
        J := TJSONObject.ParseJSONValue(temp) as TJSONObject;
        if J.Count > 0 then
          Result := J.GetValue('media_id').Value;
      finally
        J.Free;
        readnum.Free;
        ad.Free;
      end;
    end;

    作者微信:Leedege

  • 相关阅读:
    JAVA软件开发职责
    Redis主从复制配置
    VirtualBox安装Ubuntu教程
    分段锁——ConcurrentHashMap
    阻塞队列BlockingQueue用法
    阻塞队列--LinkedBlockingQueue
    MySQL百万级数据库优化方案
    获取主机的对外ip
    联通沃云开启80端口
    Nginx 正则匹配
  • 原文地址:https://www.cnblogs.com/devinlee/p/4565933.html
Copyright © 2011-2022 走看看