I'm trying to extract the page number of a ChannelAdvisor Inventory List but it always output EMPTY.
here is my code:
<?php
$url = "https://merchant.channeladvisor.com/AM/MyInventory/View_Inventory.aspx?apid=32001263";
$str = file_get_contents($url);
preg_match('/<span id="Surround_ctl00_Surround_Content_Paging_ctl00_l1"> of (.*?)<\/span> /',$str,$as);
var_dump($as);
?>
I'm trying to extract the 340..
You will probably want to investigate Curl, the address you are trying to access is HTTPS and requires authentication. This is probably why you aren't getting back any data.
PHP CURL
Related
I’m trying to call a URL and read its content using php.
when I place the url directly in the browser It works, but when I use php it returns empty string.
here’s my code:
$url = "https://www.instagram.com/instagram/?__a=1"
$json = file_get_contents($url);
$res= json_decode($json);
var_dump($res);
Does anyone have an idea why I can’t read the file with PHP?
Thank you,
So I am trying to get some information from a JSON file. But for some reason there is no actual response with the information that I need.
This is the code im running.
$json_object = file_get_contents('http://steamcommunity.com/profiles/'.$steamID.'/inventory/json/730/2');
$json_decoded = json_decode($json_object);
echo $json_decoded->success;
I get the steamID from a cookie. But if you want to see how the JSON looks, then you can check out this link:
http://steamcommunity.com/profiles/76561198031313244/inventory/json/730/2
The problem is that the URL you are checking is redirected to another URL, file_get_contents() doesn't support following redirects AFAIK, so you should better use cURL
Check this answer https://stackoverflow.com/a/4324018/5658508
the problem is like the others tell you is in this link http://steamcommunity.com/profiles/76561198031313244/inventory/json/730/2
i just monitor the response, so when you visit the link you get a 302 Moved Temporarily http response to the new link which is http://steamcommunity.com/id/SANDISS/inventory/json/730/2
you can try to get contents using file_get_contents if you have the link not just a steam id, or use curl library
I'm trying to read aliexpress.com deals page via php. I'm not able to get the details of the page in output.
Is there a way I can get the details.
Below is the code.
<?php
include('simple_html_dom.php');
$url = 'http://activities.aliexpress.com/superdeals.php';
$xml = file_get_html($url);
//$file = 'output1.txt';
$element = $xml;
echo $element;
?>
This website used AJAX
There are two solutions :
- Make the same request as Javascript
- Using a tool like Phantomjs
If you look at requests, you will find easily that a GET request is made and return all information in JSON.
So you need to find by yourself the link or use third party library + tools.
EDIT:
You can use your web browser to get the link (I don't give you it because i think stackoverflow is not for that) with firebug or if you're using chrome, in network tab search for the JSON.
$url = "....";
$str = file_get_contents($url);
if($str) {
$json = json_decode($str, true); // json is an array
// ... do what you need
}
I recommend to use curl instead of file_get_contents for many reasons.
Or you can use Phantomjs (it's really more difficult) and get a "HTML snapshot" and then use DOM or XPATH to get what you need, but you must run Phantomjs and use a third party library for communicate with it.
I am working with PHP.
I'm trying to get the HTML code from DHL's tracking website, in order to parse it, given a certain tracking number and other parameters.
The response seems to send an empty HTML, but if I try the link in a browser, it works.
Does anyone have an idea why this is happening?
<?php
$url = 'http://www.dhl.com.mx/content/mx/en/express/tracking.shtml?brand=DHL&AWB='.$shipment_number.'%0D%0A';
$html = file_get_contents($url);
$dom->loadHTML($html);
$xpath = new DomXPath($dom);
?>
It's seem that the page Require User agent to access,they does not allow Bot
You can use CURL and set user agent as browser to get the page content
I have a script on my server send sends email. and shows a response as 0 or 1
Here is the URL :
http://examplewebsite.com/emailsender.php?to=$to&subject=$subject&message=$message
I am punting data in $to,$messages,$header.And it's sending the email.
I need to get the response of the page too.
How can i do that?
use file_get_contents or curl to get the output:
$output = file_get_contents(" http://smwebtech.com/webservices/emailsender.php?to=$to&subject=$subject&message=$message");
The URL can be called with file_get_contents() or cURL, both will give you the resulting HTML.
You should implement some sort of security to prevent people abusing your email script, such as an IP whitelist.
In PHP there are a number of ways. The easiest is file_get_contents() (which supports URL wrappers), or if you want a bit more power but more setup you can use CURL.
<?php
$response = file_get_contents('http://smwebtech.com/webservices/emailsender.php?to=$to&subject=$subject&message=$message');
var_dump($response);
?>