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


PHP Snoopy::set_submit_normal方法代码示例

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


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

示例1: sendPostRequest

 public static function sendPostRequest($url, $postParameters, $responseType = 'raw')
 {
     $snoopy = new Snoopy();
     $snoopy->accept = 'application/json';
     $snoopy->set_submit_normal();
     $snoopy->submit($url, $postParameters);
     $response = null;
     switch ($responseType) {
         case 'json':
             $response = json_decode($snoopy->results);
             break;
         case 'raw':
             $response = $snoopy->results;
             break;
         default:
             $response = $snoopy->results;
     }
     // on failure, throw an exception
     if ($snoopy->status != 200) {
         if ($responseType == 'raw') {
             throw new HttpException($response, $snoopy->status);
         } elseif ($responseType == 'json') {
             if (isset($response->field_errors) && !empty($response->field_errors)) {
                 $errorMsg = "[";
                 $i = 0;
                 foreach ($response->field_errors as $field_error) {
                     $errorMsg .= $i != 0 ? ' | ' . $field_error : $field_error;
                     ++$i;
                 }
                 $errorMsg .= "]";
                 throw new HttpException($response->message . ' => ' . $errorMsg, $snoopy->status);
             } else {
                 throw new HttpException($response, $snoopy->status);
             }
         }
     }
     return $response;
 }
开发者ID:NaszvadiG,项目名称:activeCollab-PHP-API-Library,代码行数:38,代码来源:AcHelper.class.php

示例2: sendPreview

 /**
  * 发送预览图文消息
  * @param string $account 账户名称
  * @param string $title 标题
  * @param string $summary 摘要
  * @param string $content 内容
  * @param string $photoid 素材库里的图片id(可通过uploadFile上传后获取)
  * @param string $srcurl 原文链接
  * @return json
  */
 public function sendPreview($account, $title, $summary, $content, $photoid, $srcurl = '')
 {
     $send_snoopy = new Snoopy();
     $submit = "https://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 = 'https://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);
     $post['token'] = $this->_token;
     $send_snoopy->submit($submit, $post);
     $tmp = $send_snoopy->results;
     $this->log('step2:' . $tmp);
     $json = json_decode($tmp, true);
     return $json;
 }
开发者ID:hexi,项目名称:wechat-php-sdk,代码行数:25,代码来源:Wechatext.class.php

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