开发者

Want to retrieve academic result data from the other site to my site [closed]

开发者 https://www.devze.com 2023-01-16 06:19 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 9 years ago.

I am creating a academic/community site in Joomla . One of my site requirement is to obtain the result from the official college site . I will be creating a module on my site which will have college id as input and on submission it will show the result obtained from the official website .

I am finding it difficult to pass the data from one site to other . The official website is using Post method for college id input .

Please help me with detailed appr开发者_运维知识库oach with programming code sample . It will be highly appreciated . Thanks.


You will need something like PHP CURL for your problem. Your code could be something like:

<?php 

$url = "http://www.collegesite.com"; 
$ch = curl_init();    // initialize curl handle 
curl_setopt($ch, CURLOPT_URL,$url); // set url to post to 
curl_setopt($ch, CURLOPT_FAILONERROR, 1); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects 
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable 
curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s 
curl_setopt($ch, CURLOPT_POST, 1); // set POST method 
curl_setopt($ch, CURLOPT_POSTFIELDS, "collegid=40"); // add POST fields 
$result = curl_exec($ch); // run the whole process 
curl_close($ch);  
echo $result; 
?> 

Then you can use regex to get whatever data you want from $result. You may want to read the net up a bit about CURL.

0

精彩评论

暂无评论...
验证码 换一张
取 消