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}
Related
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.
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 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>";
}
I'm trying to get a list of domains from SimpleDB using PHP and the official Amazon AWS PHP SDK. My code gets something, but it seems to be looping through the wrong stuff.
Here is my code:
<?php
// Include the SDK
require_once 'sdk.class.php';
// Include the SDK
$sdb = new AmazonSDB();
$domainList = $sdb->listDomains();
echo "<pre>";
print_r($domainList, false);
echo "</pre>";
echo "<br><br><br>";
if ($domainList) {
foreach ($domainList as $domainName) {
$domain_name = $domainName->ListDomainsResult->DomainName;
echo "Domain: " . $domain_name . "<br>";
}
}
echo "<br><br><br>";
$request_id = $response->body->ResponseMetadata->RequestId;
$cost = $response->body->ResponseMetadata->BoxUsage;
echo "Request ID: " . $request_id . "<br>";
echo "Cost: " . $cost . "<br>";
?>
A the moment I get the following output
Domain:
Domain: test05
Domain:
I should get:
test05
test06
test07
It is easier than I thought. There is an easier command to use:
Here is the code:
<?php
// Include the SDK
require_once 'sdk.class.php';
// Include the SDK
$sdb = new AmazonSDB();
// Get list of domains
$domains = $sdb->get_domain_list();
// echo "<pre>";
// print_r($domains, false);
// echo "</pre>";
foreach ($domains as $domain)
{
echo "Domain: " . $domain . "<br>";
}
?>
i'm stuck at this facebook application, not knowing how do i go ahead.
for the canvas, the app works quite perfectly. i've two pages, quote.html and quote.php. in quote.html, quote.php [which gets the quotes from the database] is called through ajax which displays a quote randomly for 10 secs.
however, for the wall tab/profile box, i can't seem to know where i'm going wrong. i created a page called 'profile_box.php', call quote.php for the quotes, setFBML. while this works on canvas [sans the timing], it doesn't display anything on the wall tab.
<?php
include 'quote.php';
$row = mysql_fetch_array($result, MYSQL_ASSOC);
if ( !$row ) {
echo "Empty";
}
else{
$fb_box = "<p>" . h($row['cArabic']) . "</p>";
$fb_box .= "<p>" . h($row['cQuotes']) . "</p>";
$fb_box .= "<p>" . h($row['vAuthor']) . "</p>";
$fb_box .= "<p>" . h($row['vReference']) . "</p>";
}
try{
$url="http://website/name/quote.html";
$facebook->api_client->fbml_refreshRefUrl($url);
$fbml = "<fb:ref url='$url'/>";
if(isset($_REQUEST['fb_sig_page_id'])){
$page_id = $_REQUEST['fb_sig_page_id'];
$profile_type = $_REQUEST['fb_sig_type'];
$facebook->api_client->profile_setFBML($appapikey, $page_id, "$fbml", NULL, NULL, "$fb_box");
}
else {
$is_tab = isset($_REQUEST['fb_sig_in_profile_tab']);
if( !$is_tab ) $user_id = $facebook->require_login();
$result = $facebook->api_client->profile_setFBML($appapikey, $user_id, "$fbml", NULL, NULL, "$fb_box");
}
}
catch(Exception $ex){
echo 'Caught exception: ', $ex->getMessage(), "\n";
}
echo "<fb:add-section-button section=\"profile\" /><br />";
?>
can anyone please give any pointers?
I hate to be the bearer of bad news, but Profile Boxes and the Boxes Tab are gone.
They are being replaced with Application Tabs.
In other words, you will no longer be able to display custom content on a user's profile. It all has to go into a application-specific tab.