Image retrieval problems

Source: Internet
Author: User
Get picture question http://api.94qing.com/verify.php
This address
I tried it many times. I don't want to instruct you how to get the verification code for this address. it is written to the local directory and displayed.


Reply to discussion (solution)

Get the local directory and display... what is your intention?

@ PhpNewnew display verification code

Get the local directory and display... what is your intention?


The obtained verification code is displayed. after the website requires the user to enter the verification code, the user can continue to call the website.

I didn't understand what you mean:
Is Local your own website? If there are two methods:
1,
2 |

$img=file_get_contents("http://api.94qing.com/verify.php");header("content-type:image/jpeg");echo $img;


Hope to help you

I didn't understand what you mean:
Is Local your own website? If there are two methods:
1,
2 |

$img=file_get_contents("http://api.94qing.com/verify.php");header("content-type:image/jpeg");echo $img;


Hope to help you


How can I retrieve and modify the image and save it locally before reading it?

File_put_contents ('image filename ', $ img );


However, your connection is a verification code image with sessionID
Normal image processing cannot work.

Want to cross-origin .... this is okay if you make a client to keep the connection... if you use your current logic to set up a local website for another person's website... then you can reference the image address directly.

Use curl to simulate the verification code and store the Cookie obtained by curl. when you send data (Curl sends data), this Cookie is carried.

To put it bluntly, I have found that the api call for this website is like this. Before that, I said that I want to access a cookie to call the api. but now I have added a verification code and a verification code. solve the verification code problem-so it is expected that the visitor can use the verification code because the cookie is valid for one day, so only one person can use the verification code. Therefore, obtain the image locally and then display the user ip address. the obtained verification code does not seem to work.

Obviously, your thinking is correct.
I wrote a test example.

session_start();header('Content-type: text/html;charset=utf-8');include 'curl/curl_get.php';$url = 'http://api.94qing.com/';if(isset($_GET['img'])) {  curl_get($url);  echo curl_get($url . 'verify.php');  exit;}switch(1) {  case isset($_POST['code']):    $_SESSION['94qing'] = $_POST['code'];    curl_get($url . "?code=$_POST[code]");  case isset($_SESSION['94qing']):    echo curl_get("$url?type=time");    break;  default:    echo <<< FORMFORM;  exit;}
The first time you enter a form with a verification code entered, you do not need to refresh it later.
For simplicity, only the api that obtains the current time is used as an example.

The curl_get function has been pasted too many times, but it only covers common settings.
Paste it again.
Function curl_get ($ durl, $ data = array () {$ cookiejar = realpath('cookie.txt '); $ t = parse_url ($ durl); $ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, $ durl); curl_setopt ($ ch, CURLOPT_TIMEOUT, 5); curl_setopt ($ ch, hour, 0); curl_setopt ($ ch, CURLOPT_USERAGENT, $ _ SERVER ['http _ USER_AGENT ']); curl_setopt ($ ch, CURLOPT_REFERER, "HTTP: // $ t [host]/"); curl_setopt ($ ch, CURLOPT_COOKIEFILE, $ cookiejar); curl_setopt ($ ch, CURLOPT_COOKIEJAR, $ cookiejar); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ ch, CURLOPT_ENCODING, 1 ); // gzip decoding curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, true); if ($ data) {curl_setopt ($ ch, CURLOPT_POST, 1); curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ data) ;}$ r = curl_exec ($ ch); curl_close ($ ch); return $ r ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.