I took a part of PHP code from a different Stackoverflow question, and it works perfectly.
<?php header>
//Display IceCast Server Stats
$server = "***********"; //IP (x.x.x.x or domain name)
$iceport = "8070"; //Port
$iceurl = "live"; //Mountpoint
$online = "<font color=green><b>ONLINE</b> </font><br />";
$offline = "<font color=red><b>OFFLINE</b></font><br />";
if($fp = #fsockopen($server, $iceport, $errno, $errstr, '1')) {
fclose($fp);
$ice_status=$online;
echo "<p><b>DJ:</b> $ice_status";
$stats = file("http://" . $server . ":" . $iceport . "/status2.xsl");
$status = explode(",", $stats[5]);
$artist = explode("-", $status[5]);
echo " " . $artist[1];
echo " - ";
echo " " . $artist[2];
echo "<br />";
// echo "<b>Listeners:</b> <b> " . $status[3] . "</b>";
echo "</p>";
//echo "<br />";
//echo "<p><a href=http://" . $server . ":" . $iceport . "/" . $iceurl . " target=new><b>Listen!</b></a></p>";
} else {
$ice_status=$offline;
echo "<p><b>DJ:</b> $ice_status";
}
?>
<hr />
</center>
I'm trying to add the stream name, which is currently:
echo "DJ: $ice_status";
This displays DJ: ONLINE, but I want it to say DJ: (DJ Name/Stream Name)
I do believe its variables from status2.xsl, but I'm a complete noob at this, and can't seem to figure out how to use it. Could anyone tell me what streamname variable would be?
I was also wondering, is it possible to make it so the "nowplaying.php" refreshes, but my whole web page doesn't? I've tried an iframe, but it makes it look really bad, and has errors.
What my website looks like at the moment: https://i.stack.imgur.com/luc4O.jpg
I'd suggest having a look at TheFineManualâ„¢:
http://icecast.org/docs/icecast-2.4.1/server-stats.html#xslt
Especially the part about status-json.xsl. Make sure you are running an up to date version of Icecast. Icecast is available from all major Linux distributions in up to date packaging. Xiph provides independent packaging, which is useful if there are no up to date packages for a distribution, e.g. shortly after an Icecast release.
status2.xsl was an example file, and a bad one at that. It was removed from newer Icecast versions.
Related
I have a small issue, I'm currently trying to display a user's inventory using steam's API, everything that I wanted is done. (it gets the players items, name and displays the skin's image) however it takes a good 9-30seconds for the webpage to load, is it possible to make the loading of the data faster?
<?php
if(!isset($_SESSION["steamid"])): ?>
<a> Log In so you can see your inventory! </a>
<?php else: ?>
<div class="GetInventory">
<?php
$player = file_get_contents("http://steamcommunity.com/profiles/" . $_SESSION["steamid"] . "/inventory/json/730/2");
$player = json_decode($player, true);
foreach($player["rgDescriptions"] as $item) {
$result = #file_get_contents("http://steamcommunity.com/market/priceoverview/?currency=3&appid=730&market_hash_name=" . str_replace(" ", "%20", $item["market_hash_name"]));
$result = json_decode($result, true);
if(!empty($result["success"]) && $result["success"] == true && !empty($result["median_price"]))
echo '<img id= "skinimg" src="http://steamcommunity-a.akamaihd.net/economy/image/' . $item["icon_url"] . '"> ' . $item["name"] . " - " . $result["median_price"] . "<br>";}
?>
<?php endif; ?>
This is the code I currently have,does anyone have any sugestion?
http://i.imgur.com/rRP3Ne0.png
I really don't know Drupal but have managed to create a simple HTML page that I would like to use the first and last name inputted to run snoopy.class.php to run a script on a web site to retrieve some data. The button should run a function that will submit the URL but I am not getting any results.
Because I don't know how to debug in Drupal I added some echo statements to see how far the code ran it seems to be stopping when it tries to create a new snoopy object. I downloaded the class and put it in what I would think would be an accessible folder, namely public_html/tools it:
-rw-r--r-- 1 agentpitstop apache 37815 Sep 3 21:03 Snoopy.class.php
Below is the code I am using
<form method="post">
<p>Last Name: <input type="text" name="lastname" /><br />
First Name: <input type="text" name="firstname" /></p>
<p><input type="submit" value="Send it!"></p>
</form>
<?php
if($_POST)
{
echo "1st display <br />\n";
$url = "https://pdb-services-beta.nipr.com/pdb-xml-reports/hitlist_xml.cgi?";
$url = $url . "customer_number=beta83agent&pin_number=nipr123&report_type=1";
$lastname = $_POST['lastname'];
$firstname = $_POST['firstname'];
$parms = array("name_last"=>$lastname,"name_first"=>$firstname);
echo "2nd display <br />\n";
$result = curl_download($url,$parms);
$xml=simplexml_load_file("$result.xml");
$nipr_id = $xml->NPN;
echo "url " . $url . "<br />\n";
echo "Agent " . $_POST['firstname'] . " " . $_POST['lastname'] . " Id is:". $nipr_id . "<br />\n";
echo "3rd Result from call " . $result . "<br />\n";
}
?>
<?php
include "Snoopy.class.php";
function curl_download($url,$parms)
{
echo "in call to curldownload ";
$snoopy = new Snoopy();
echo "after setting object";
$snoopy->curl_path = "/usr/bin/curl"; # Or whatever your path to curl is - 'which curl' in terminal will give it to you. Needed because snoopy uses standalone curl to deal with https sites, not php_curl builtin.
echo "after setting path";
$snoopy->httpsmethod = "POST";
echo "after setting post";
$snoopy->submit($url, $parms);
echo "after setting submit";
print $snoopy->results;
echo "results: " . results;
return $snoopy->results;
}
?>
Any help would be appreciated.
If you need custom development on a Drupal site create a custom module and use Drupal's form API.
If you need to perform HTTP request from PHP, use a PHP library/extension, such a php-curl, Guzzle or Drupal's drupal_http_request(). And yes, they all support HTTPS.
I'm trying to get a list of videos for a specific user with all the details for the video (title, desc., date, tags...)
I can get pretty much everything I need, but can't figure out how to get the upload date.
I tried using getVideoRecorded() and getRecorded(), but both return nothing.
I can't seem to find anything related to this on Google, all I can find is class references which tell me that I have to use getVideoRecorded or getRecorded, but nothing more.
Am I doing something wrong? how can I get the upload date?
Current code:
$authenticationURL= 'https://www.google.com/accounts/ClientLogin';
$httpClient =
Zend_Gdata_ClientLogin::getHttpClient(
$username = $yt_username,
$password = $yt_password,
$service = 'youtube',
$client = null,
$source = '', // a short string identifying your application
$loginToken = null,
$loginCaptcha = null,
$authenticationURL);
$yt = new Zend_Gdata_YouTube($httpClient);
$feed = $yt->getUserUploads($yt_username);
foreach($feed as $item)
{
echo "<div>";
echo "<h4>title: " . $item->getVideoTitle() . "</h4>";
echo "<p>id: " . $item->getVideoId() . " | ";
echo "upload date: " . $item->getVideoRecorded() . "</p>";
echo "<p>description: " . $item->getVideoDescription() . "</p>";
echo "<p>tags: " . implode(", ", $item->getVideoTags()) . "</p>";
echo "</div>";
echo "<hr>";
}
You can try and extract the < published > or < updated > tags from the following xml:
http://gdata.youtube.com/feeds/api/videos/{$videoId}
I still have trouble with the new google_api_client php library. I'm trying to retrieve the user's contacts.
I'm very close to the right solution ... I mean, I just got all the results but a can't parse it.
Probably it's because I'm not strong with XML parser. After tests and tests ... I get this solution (based on the example file by Google):
...
$req = new apiHttpRequest("https://www.google.com/m8/feeds/contacts/default/full");
$val = $client->getIo()->authenticatedRequest($req);
$response = simplexml_load_string($val->getResponseBody());
foreach($response->entry as $entry)
{
$child = $entry->children("http://schemas.google.com/g/2005");
$mail_info = $child->attributes();
}
...
In the $response I can get the title field where my contact's full name is stored, and in the $mail_info a got an object where i see the address field when I get the email address.
It's SAD and UGLY solution ... what if I want the company name, address ... phone numbers ... photos. Where are all these informations.
How can I use the Google response in a great and clean solution?
Anyone can give me some help.
Bye
What helped me was requesting JSON instead of XML. Try adding ?alt=json to the end of the URL in the request you make to google.
$req = new apiHttpRequest("https://www.google.com/m8/feeds/contacts/default/full?alt=json");
$val = $client->getIo()->authenticatedRequest($req);
$string = $val->getResponseBody();
$phparray = json_decode($string);
Certainly not child's play to get what you want but working with php arrays is probably easier.
For completeness this is the google contacts php example that we both probably found that helped us:
https://code.google.com/p/google-api-php-client/source/browse/trunk/examples/contacts/simple.php
EDIT:
Here is another link that might help. In the comments it describes a cleaner of accessing contact's data using JSON.
http://25labs.com/import-gmail-or-google-contacts-using-google-contacts-data-api-3-0-and-oauth-2-0-in-php/
$url = 'https://www.google.com/m8/feeds/contacts/default/full?max-results='.$max_results.'&alt=json&v=3.0&oauth_token='.$accesstoken;
$xmlresponse = curl_file_get_contents($url);
$temp = json_decode($xmlresponse,true);
foreach($temp['feed']['entry'] as $cnt) {
echo $cnt['title']['$t'] . " --- " . $cnt['gd$email']['0']['address'] . "</br>";
}
and
$url = 'https://www.google.com/m8/feeds/contacts/default/full?max-results='.$max_results.'&alt=json&v=3.0&oauth_token='.$accesstoken;
$xmlresponse = curl_file_get_contents($url);
$temp = json_decode($xmlresponse,true);
foreach($temp['feed']['entry'] as $cnt) {
echo $cnt['title']['$t'] . " --- " . $cnt['gd$email']['0']['address'];
if(isset($cnt['gd$phoneNumber'])) echo " --- " . $cnt['gd$phoneNumber'][0]['$t'];
if(isset($cnt['gd$structuredPostalAddress'][0]['gd$street'])) echo " --- " . $cnt['gd$structuredPostalAddress'][0]['gd$street']['$t'];
if(isset($cnt['gd$structuredPostalAddress'][0]['gd$neighborhood'])) echo " --- " . $cnt['gd$structuredPostalAddress'][0]['gd$neighborhood']['$t'];
if(isset($cnt['gd$structuredPostalAddress'][0]['gd$pobox'])) echo " --- " . $cnt['gd$structuredPostalAddress'][0]['gd$pobox']['$t'];
if(isset($cnt['gd$structuredPostalAddress'][0]['gd$postcode'])) echo " --- " . $cnt['gd$structuredPostalAddress'][0]['gd$postcode']['$t'];
if(isset($cnt['gd$structuredPostalAddress'][0]['gd$city'])) echo " --- " . $cnt['gd$structuredPostalAddress'][0]['gd$city']['$t'];
if(isset($cnt['gd$structuredPostalAddress'][0]['gd$region'])) echo " --- " . $cnt['gd$structuredPostalAddress'][0]['gd$region']['$t'];
if(isset($cnt['gd$structuredPostalAddress'][0]['gd$country'])) echo " --- " . $cnt['gd$structuredPostalAddress'][0]['gd$country']['$t'];
echo "</br>";
}
So i installed XMAPP to view my php site im developing for a php mysql class at my local college and I ran aground hours ago and have been searching frantically for answers since. whenever i try to view my site all i see is this
" . $row['tid'] . ""; echo $id; $thisName = "\n
" . $row['fname'] . " " . $row['lname'] ."
"; echo $thisName; $description = "\n
" . nl2br($row['description']) . "
"; echo $description; echo ""; } include ("footer.php"); ?>
or something similar. we host on a local server that has everything we need but cannot access it from our homes. I was wondering if anyone could lend me a hand?
It looks like you have an echo statement where you're using a single quote to open a string but not close it. For instance:
echo '" . $row['tid'] . ""; echo $id; $thisName = "
Go search in your source for something like this. I'd bet that this is your error.