I'm trying to scrape a website (www.glturk.com).
When I run the below link via a browser:
http://www.glturk.com/ajax.aspx?stream=live&type=free&ppoint=ATVTurkiye_LR
I get the following response:
http://38.117.88.248:7777/ATVTurkiye_LR.m3u8?user=sglsxxdewfiduaqygnbfnqwcuc55&session=e0e8f5e6dbfb83be9e4f1155454b43d14130b7e79528a6fbe8dcb832c9f2cef0fbecdaf0092c93ab9826978c8d46626c20ba4293a32569e6e7cfbbd9d61c69ad
The above M3U8 link works perfectly in that instance.
But, if I try to replicate this via a PHP file, I get a very similar result, but that m3u8 link does not work?!
<?php
$channelURL= 'http://www.glturk.com/ajax.aspx?stream=live&type=free&ppoint=ATVTurkiye_LR';
$actualLink = file_get_contents($channelURL, TRUE);
echo $actualLink;
?>
The result I get is:
http://38.117.88.249:7777/ATVTurkiye_LR.m3u8?user=sglspoqmpdi2tltn0lynorytlnvi&session=08e5fd64dca2f17d9e4f1155454b43d136fa14cb989a57687b29865e85d60962253ac665a78595d7c5529895b22236c2f32018226b4a15e9b8327f16597d3505
This m3u8 does not work though, I can't understand why.
Working (via direct link through browser):
http://38.117.88.248:7777/ATVTurkiye_LR.m3u8?user=sglsxxdewfiduaqygnbfnqwcuc55&session=e0e8f5e6dbfb83be9e4f1155454b43d14130b7e79528a6fbe8dcb832c9f2cef0fbecdaf0092c93ab9826978c8d46626c20ba4293a32569e6e7cfbbd9d61c69ad
Not Working (via PHP):
http://38.117.88.249:7777/ATVTurkiye_LR.m3u8?user=sglspoqmpdi2tltn0lynorytlnvi&session=08e5fd64dca2f17d9e4f1155454b43d136fa14cb989a57687b29865e85d60962253ac665a78595d7c5529895b22236c2f32018226b4a15e9b8327f16597d3505
Any advise would be appreciated :) Thank you!
Related
I´m trying a very simple php script which is about calling a json data through api calling on a online https link using MAMP.
However if I use the following code I have blank results:
<?php
$cnmkt = "https://api.coinmarketcap.com/v1/ticker/?limit=50";
$json = file_get_contents($cnmkt);
$fgc = json_decode($json,true);
echo $fgc[1]['percent_change_7d'];
?>
But if i copy/paste the content of the https link into a test.json file locally, substituting the https link with the test.json file on $cnmkt variable, the same exact script works properly.
I know i´m missing something very obvious, if someone could help me that would be very much appreciated, thanks.
Stefano
The script is working fine. I get an expected result of 4.63
Disable your AV/firewall and check again.
I tried the following coding for a 'UIWebView:
let kapitel3 = "<html><head><title>Chapter 1</title></head><body><h1>This is a title!</h1></body></html>"
This HTML code works fine and "UIWebView" shows this code. But if I try to insert a PHP code within the HTML code like this:
let kapitel3 = "<html><head><title>Chapter 1</title></head><body><h1>This is a title!</h1><?php print \"Hello world!\";?></body></html>"
Then the PHP code won't be showed. Why doesn't 'UIWebView' translate this PHP code <?php print \"Hello world!\";?>?
Is it not possible to integrate PHP code in a String like above?
Thanks for any hints!
UIWebView is only a simple web-browser...
You can't use php like that if you don't have a local webserver with a php interpreter installed!
You could load a php page from a remote url but your phone must have an active internet connection...
Possible local solution:
You can't use php locally, but in a UIWebView you can still use javascript!
I don't know what you are trying to do...but if you need your app to work offline (with local files) using php is the wrong approach.
I want to get the distance from one point to another using the google API, but I'm having some issues.
My API link is:
http://maps.googleapis.com/maps/api/directions/json?origin=55.061744,9.429565&destination=Opnæsgård,%20Hørsholm,%20Denmark&alternatives=true&sensor=false
If I access this link from the browser, I get the correct distance however; when I try to access the exact same URL from my php script, I get an error.
My php script:
<?php
print_r(file_get_contents('http://maps.googleapis.com/maps/api/directions/json?origin=55.061744,9.429565&destination=Opnæsgård,%20Hørsholm,%20Denmark&alternatives=true&sensor=false'));
?>
Output from php script:
{ "routes" : [], "status" : "NOT_FOUND" }
As you can see, I'm getting two different results with the same URL, and I have no idea why.
I have also tried using CURL in the php script without any luck.
I hope you can help me
//Mikkel
I want to access some function written in some php file on another server and receive the input, I have access to those server files so that I can change them for proper configuration, I have all the privilleges to do so, can anybody please guide me how can I do it, thank you
$result = file_get_contents("http://some.server/out.php");
and in this out.php
<?php
include 'some.php';
function();
I think you can implement web service or an api, and the output could be in xml or json read the content and use it on your website.
It is just Facebook graph API using URL
https://graph.facebook.com/Pepsi
The above link will fetch information regarding Facebook page of Pepsi.
I need to get the XML data from youtube for a particular video(based on ID) and fetch the thumbnail url. I am using PHP.
The code is as follows:
<?php
//$xmlFilePath = 'http://localhost/testFile.xml'; //This works..
$xmlFilePath = 'https://gdata.youtube.com/feeds/api/videos/5P6UU6m3cqk?v=2';
$dataFromYoutube = file_get_contents($xmlFilePath);
print_r($dataFromYoutube);
?>
I dont get any data. The output is blank. If I load the url 'https://gdata.youtube.com/feeds/api/videos/5P6UU6m3cqk?v=2' in browser and copy the content to a file(http://localhost/testFile.xml), then the above code works.
I have tried fetching the youtube data using ajax and also simlexml_load_file function in php. But the result is blank/empty for Youtube url. However, I get the data for 'http://localhost/testFile.xml' in both cases.
How can I fetch youtube data using php?
Please help.
well, your code is correct and works fine too. It may be that your apache server is not configured for "https". So just check it once too.