JD Graph bed upload interface PHP source code

JD Graph bed upload interface PHP source code

Where is the most stable map bed.

Sina, JD, Taobao, Baidu, Sogou. three hundred and sixty

But generally speaking, it is Jingdong, Taobao is relatively stable!

The following is the upload code of JD Graph Bed PHP

  1. <? php
  2. /*
  3. *JD Graph Bed PHP code
  4. *AE Blog
  5. *   www.aeink.com
  6. */
  7. if  ( class_exists ('CURLFile')) {  // php 5.5
  8.      $post ['file'] =  new  \CURLFile( realpath ( $_FILES ['Filedata']['tmp_name']));
  9. else  {
  10.      $post ['file'] = '@'. realpath ( $_FILES ['Filedata']['tmp_name']);
  11. }
  12. $rel  = get_curl('https: //search.jd.com/image? op=upload',$post);
  13. preg_match('/callback(?:\(\ ")(.*)(?:\"\))/i',$rel,$matches);
  14. if (!$matches[1]) {
  15. Exit ('Image upload failed! ');
  16. }
  17. $arr = array(
  18.     'code'  =>  200,
  19.     'imgurl'=>  ' https://img '.rand(10,14).'. 360buyimg.com/uba/'.$ matches[1]
  20. );
  21. exit(json_encode($arr));
  22. function get_curl($url, $post=0, $referer=0, $cookie=0, $header=0, $ua=0, $nobaody=0){
  23.     $ch = curl_init();
  24.     curl_setopt($ch, CURLOPT_URL, $url);
  25.     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  26.     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  27.     $httpheader[] = " Accept:application/json ";
  28.     $httpheader[] = " Accept-Encoding:gzip,deflate,sdch ";
  29.     $httpheader[] = " Accept-Language:zh-CN,zh;q=0.8 ";
  30.     $httpheader[] = " Connection:close ";
  31.     curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
  32.     if ($post) {
  33.         curl_setopt($ch, CURLOPT_POST, 1);
  34.         curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  35.     }
  36.     if ($header) {
  37.         curl_setopt($ch, CURLOPT_HEADER, true);
  38.     }
  39.     if ($cookie) {
  40.         curl_setopt($ch, CURLOPT_COOKIE, $cookie);
  41.     }
  42.     if($referer){
  43.         if($referer==1){
  44.             curl_setopt($ch, CURLOPT_REFERER, ' http://m.qzone.com/infocenter?g_f= ');
  45.         }else{
  46.             curl_setopt($ch, CURLOPT_REFERER, $referer);
  47.         }
  48.     }
  49.     if ($ua) {
  50.         curl_setopt($ch, CURLOPT_USERAGENT, $ua);
  51.     }
  52.     else {
  53.         curl_setopt($ch, CURLOPT_USERAGENT, " Mozilla/5.0 (Linux; U; Android 4.0.4; es-mx; HTC_One_X Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 ");
  54.     }
  55.     if ($nobaody) {
  56.         curl_setopt($ch, CURLOPT_NOBODY, 1);
  57.     }
  58.     curl_setopt($ch, CURLOPT_TIMEOUT, 3);
  59.     curl_setopt($ch, CURLOPT_ENCODING, " gzip");
  60.     curl_setopt( $ch , CURLOPT_RETURNTRANSFER, 1);
  61.      $ret  = curl_exec( $ch );
  62.     curl_close( $ch );
  63.      return   $ret ;
  64. }

Interested friends can try

 

 Watson Blog
  • This article is written by Published on February 18, 2019 00:15:56
  • This article is collected and sorted by the website of Mutual Benefit, and the email address for problem feedback is: wosnnet@foxmail.com , please keep the link of this article for reprinting: https://wosn.net/1625.html

Comment