当前位置: 首页>>代码示例>>PHP>>正文


PHP Snoopy::set_submit_multipart方法代码示例

本文整理汇总了PHP中Snoopy::set_submit_multipart方法的典型用法代码示例。如果您正苦于以下问题:PHP Snoopy::set_submit_multipart方法的具体用法?PHP Snoopy::set_submit_multipart怎么用?PHP Snoopy::set_submit_multipart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Snoopy的用法示例。


在下文中一共展示了Snoopy::set_submit_multipart方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: uploadFile

 /**
  * 上传附件(图片/音频/视频)
  * @param string $filepath 本地文件地址
  * @param int $type 文件类型: 2:图片 3:音频 4:视频
  */
 public function uploadFile($filepath, $type = 2)
 {
     $send_snoopy = new Snoopy();
     $send_snoopy->referer = "http://mp.weixin.qq.com/cgi-bin/indexpage?t=wxm-upload&lang=zh_CN&type=2&formId=1";
     $t = time() . strval(mt_rand(100, 999));
     $post = array('formId' => '');
     $postfile = array('uploadfile' => $filepath);
     $send_snoopy->rawheaders['Cookie'] = $this->cookie;
     $send_snoopy->set_submit_multipart();
     $submit = "http://mp.weixin.qq.com/cgi-bin/uploadmaterial?cgi=uploadmaterial&type={$type}&token=" . $this->_token . "&t=iframe-uploadfile&lang=zh_CN&formId=\tfile_from_" . $t;
     $send_snoopy->submit($submit, $post, $postfile);
     $tmp = $send_snoopy->results;
     $this->log('upload:' . $tmp);
     preg_match("/formId,.*?\\'(\\d+)\\'/", $tmp, $matches);
     if (isset($matches[1])) {
         return $matches[1];
     }
     return false;
 }
开发者ID:hexi,项目名称:wechat-php-sdk,代码行数:24,代码来源:Wechatext.class.php

示例2: uploadFile

 /**
  * 上传附件(图片/音频/视频)
  * @param string $username 用户ticket_id名称
  * @param string $filepath 本地文件地址
  * @param int $type 文件类型: 2:图片 3:音频 4:视频
  */
 public function uploadFile($filepath, $type = 2)
 {
     $send_snoopy = new Snoopy();
     $send_snoopy->referer = "https://mp.weixin.qq.com/cgi-bin/filepage?type=2&begin=0&count=10&t=media/list&token=" . $this->_token . "&lang=zh_CN";
     //$t = time().strval(mt_rand(100,999));
     $post['Filename'] = '';
     $post['folder'] = '/cgi-bin/uploads';
     $postfile = array('file' => $filepath);
     $send_snoopy->rawheaders['Cookie'] = $this->cookie;
     $send_snoopy->set_submit_multipart();
     $submit = "https://mp.weixin.qq.com/cgi-bin/filetransfer?action=upload_material&f=json&ticket_id=" . $this->_account . "&ticket=" . $this->getticket() . "&token=" . $this->_token . "&lang=zh_CN";
     $send_snoopy->submit($submit, $post, $postfile);
     $tmp = $send_snoopy->results;
     $this->log('upload:' . $tmp);
     $ret = json_decode($tmp, 1);
     $fileid = $ret['content'];
     return $fileid;
 }
开发者ID:KenanHuang,项目名称:gdpuer,代码行数:24,代码来源:wechatext.class.php

示例3: Snoopy

<?php

exit;
// Improvements could be made such that instead of base 64 encoding file content as a regular post string
// You can use Snoopy's file upload (MIME encoding as a regular browser)
// Needs some testing and analysis ... sample code is give below
$url = "http://www.domain.tld/pfad/zum/formular.php";
include "Snoopy.class.php";
$snoopy = new Snoopy();
// Multi-Part aktivieren, sonst können keine Dateien übertragen werden
$snoopy->set_submit_multipart();
$postVars = array();
$postVars['name'] = 'Snoopy';
$postFiles = array();
$postFiles['userfile'] = dirname(__FILE__) . '/bla.pdf';
$snoopy->submit($url, $postVars, $postFiles);
$body = $snoopy->results;
// Further all the file serving is actually done by PHP and not apache
// this can be fixed by using Apache module ‘mod_xsendfile’. ( http://www.jasny.net/articles/how-i-php-x-sendfile/ ) or https://tn123.org/mod_xsendfile/
// When serving files like this - if you want to send meta data along you can use custom http header strings
header("X-Sendfile: {$somefile}");
header("Content-type: application/octet-stream");
header('Content-Disposition: attachment; filename="' . $filename . '"');
开发者ID:pari,项目名称:rand0m,代码行数:23,代码来源:README.php

示例4: sendNews

 /**
  * 发送图文消息
  * @param string $account 账户名称
  * @param string $title 标题
  * @param string $summary 摘要
  * @param string $content 内容
  * @param string $pic 图片
  * @param string $srcurl 原文链接
  * @return json
  */
 public function sendNews($account, $title, $summary, $content, $pic, $srcurl = '')
 {
     $send_snoopy = new Snoopy();
     $send_snoopy->referer = "http://mp.weixin.qq.com/cgi-bin/indexpage?t=wxm-upload&lang=zh_CN&type=2&formId=1";
     $post = array('formId' => '');
     $postfile = array('uploadfile' => $pic);
     $send_snoopy->rawheaders['Cookie'] = $this->cookie;
     $send_snoopy->set_submit_multipart();
     $submit = "http://mp.weixin.qq.com/cgi-bin/uploadmaterial?cgi=uploadmaterial&type=2&t=iframe-uploadfile&lang=zh_CN&formId=1";
     $send_snoopy->submit($submit, $post, $postfile);
     $tmp = $send_snoopy->results;
     $this->log($tmp);
     preg_match("/formId,.*?\\'(\\d+)\\'/", $tmp, $matches);
     if (isset($matches[1])) {
         $photoid = $matches[1];
         $send_snoopy = new Snoopy();
         $submit = "http://mp.weixin.qq.com/cgi-bin/operate_appmsg?sub=preview&t=ajax-appmsg-preview";
         $send_snoopy->set_submit_normal();
         $send_snoopy->rawheaders['Cookie'] = $this->cookie;
         $send_snoopy->referer = 'http://mp.weixin.qq.com/cgi-bin/operate_appmsg?sub=edit&t=wxm-appmsgs-edit-new&type=10&subtype=3&lang=zh_CN';
         $post = array('AppMsgId' => '', 'ajax' => 1, 'content0' => $content, 'count' => 1, 'digest0' => $summary, 'error' => 'false', 'fileid0' => $photoid, 'preusername' => $account, 'sourceurl0' => $srcurl, 'title0' => $title);
         $send_snoopy->submit($submit, $post);
         $tmp = $send_snoopy->results;
         $this->log($tmp);
         $json = json_decode($tmp, true);
         return $json;
     }
     return false;
 }
开发者ID:vzina,项目名称:blog,代码行数:39,代码来源:wechatext.class.php


注:本文中的Snoopy::set_submit_multipart方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。