Help
<?php
// A simple script to get videos from yomansports by username.
// It uses the yomansports API to get all data from yomansports.
// By using username, it gets video detail from yomansporst
// IMPORTANT: get a yomansports API key from here [ http://www.yomansports.com/my_profile.php ]
$api_key = "Your yomansports API key";
if(!isset($_POST["username"])){
echo "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"POST\">";
echo "enter your YomanSports user name <input type=\"text\" name=\"username\"><input type=\"Submit\" value=\"search for yomansports videos by this user\">";
echo "</form>";
exit;
} else {
getYomanvideos($_POST["username"]);
}
function getYomanvideos($username,$page=1,$page_limit = 10) {
global $api_key, $count;
// ######## Get user_id given username
// ######## Build the API request to look up the yoman user_id
$params = array(
"api_key" => $api_key,
"method" => "yomansports.video.byUserName",
"username" => $username,
"page" => $page,
"page_limit" => $page_limit
);
$encoded_params = array();
foreach ($params as $k => $v){
$encoded_params[] = urlencode($k)."=".urlencode($v);
}
//$url = "http://api.yomansports.com/services/?".implode("&", $encoded_params);
$url = "http://www.yomansports.com/api/".implode("&", $encoded_params);
// As some PHP hosts switch off file_get_contents, here we check to see if curl is installed and use that instead.
if(function_exists("curl_init")){
$detail=curl_init($url);
curl_setopt($detail, CURLOPT_HEADER, false);
curl_setopt($detail, CURLOPT_RETURNTRANSFER, true);
$rsp=curl_exec($detail);
curl_close($detail);
} else {
$rsp = file_get_contents($url);
}
$array = simplexml_load_string($rsp);
if($array["status"] == "fail") {
if($array["error_code"] == 1)
{
echo "<b>The API key passed was not valid or has expired. - try again</b><br />";
}
elseif($array["error_code"] == 2)
{
echo "<b>User name is not valid - try again</b><br />";
}
elseif($array["error_code"] == 3)
{
echo "<b>The requested method was not found - try again</b><br />";
}
echo "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"POST\">";
echo "enter your YomanSports user nam <input type=\"text\" name=\"username\"><input type=\"Submit\" value=\"search for yomansports videos by this user\">";
echo "</form>";
exit;
}
else {
$totalCount = $array->videos["total"];
if($totalCount == 0){
echo "<b>no videos found - try again</b><br />";
echo "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"POST\">";
echo "enter your YomanSports user name <input type=\"text\" name=\"username\"><input type=\"Submit\" value=\"search for yomansports videos by this user\">";
echo "</form>";
exit;
}
else {
if($page==1){
echo "Found a total of ".$array->videos["total"]." videos<br />";
}
echo "Page ".$page." of ".ceil($array->videos["total"]/$page_limit)."<br />";
echo "<hr>";
foreach ($array->videos->video as $video){
echo "Title: <b>".$video["title"]."</b><br />";
// display the thumbnail
echo "<img src=".$video["img_src"]."><br clear=\"left\" />";
// original video page url with link
echo "<a href=\"".$video["ind_page_link"]."\">".$video["ind_page_link"]."</a><br clear=\"left\" />";
echo "Description: ".$video["description"]."<br clear=\"left\" />";
echo "Views: ".$video["views"]."<br clear=\"left\" />";
echo "keyword: ".$video["keyword"]."<br clear=\"left\" />";
echo "Add Date: ".$video["add_date"]."<br clear=\"left\" />";
echo "Added By: <a href=\"".$video["profile_link"]."\">".$video["username"]."</a><br clear=\"left\" />";
$params = array(
"api_key" => $api_key,
"method" => "yomansports.video.comment.byVideoID",
"username" => $username,
"video_id" => $video["VID"]
);
$encoded_params = array();
foreach ($params as $k => $v){
$encoded_params[] = urlencode($k)."=".urlencode($v);
}
//$url = "http://api.yomansports.com/services/?".implode("&", $encoded_params);
$url = "http://www.yomansports.com/api/".implode("&", $encoded_params);
if(function_exists("curl_init")){
$detail=curl_init($url);
curl_setopt($detail, CURLOPT_HEADER, false);
curl_setopt($detail, CURLOPT_RETURNTRANSFER, true);
$rsp_comment=curl_exec($detail);
curl_close($detail);
} else {
$rsp_comment = file_get_contents($url);
}
$array_comment = simplexml_load_string($rsp_comment);
if($array_comment->comments["total"] == 0) {
echo "There are no comments for this video<br /><hr>";
}
else {
echo "<ul>";
foreach ($array_comment->comments->comment as $comment){
echo "<li>[".$comment["username"]."] ".$comment["vdo_comment"]."</li>";
}
echo "</ul><br /><hr>";
}
}
}
}
}
?>
<?php
// A simple script to get videos from yomansports by username.
// It uses the yomansports API to get all data from yomansports.
// By using username, it gets video detail from yomansporst
// IMPORTANT: get a yomansports API key from here [ http://www.yomansports.com/my_profile.php ]
$api_key = "Your yomansports API key";
if(!isset($_POST["username"])){
echo "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"POST\">";
echo "enter your YomanSports user name <input type=\"text\" name=\"username\"><input type=\"Submit\" value=\"search for yomansports videos by this user\">";
echo "</form>";
exit;
} else {
getYomanvideos($_POST["username"]);
}
function getYomanvideos($username,$page=1,$page_limit = 10) {
global $api_key, $count;
// ######## Get user_id given username
// ######## Build the API request to look up the yoman user_id
$params = array(
"api_key" => $api_key,
"method" => "yomansports.videos.byChannelName",
"username" => $username,
"page" => $page,
"page_limit" => $page_limit,
"channel_name" => "channel Name"
);
$encoded_params = array();
foreach ($params as $k => $v){
$encoded_params[] = urlencode($k)."=".urlencode($v);
}
//$url = "http://api.yomansports.com/services/?".implode("&", $encoded_params);
$url = "http://www.yomansports.com/api/".implode("&", $encoded_params);
// As some PHP hosts switch off file_get_contents, here we check to see if curl is installed and use that instead.
if(function_exists("curl_init")){
$detail=curl_init($url);
curl_setopt($detail, CURLOPT_HEADER, false);
curl_setopt($detail, CURLOPT_RETURNTRANSFER, true);
$rsp=curl_exec($detail);
curl_close($detail);
} else {
$rsp = file_get_contents($url);
}
$array = simplexml_load_string($rsp);
if($array["status"] == "fail") {
if($array["error_code"] == 1)
{
echo "<b>The API key passed was not valid or has expired. - try again</b><br />";
}
elseif($array["error_code"] == 2)
{
echo "<b>User name is not valid - try again</b><br />";
}
elseif($array["error_code"] == 3)
{
echo "<b>The requested method was not found - try again</b><br />";
}
echo "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"POST\">";
echo "enter your YomanSports user nam <input type=\"text\" name=\"username\"><input type=\"Submit\" value=\"search for yomansports videos by this user\">";
echo "</form>";
exit;
}
else {
$totalCount = $array->videos["total"];
if($totalCount == 0){
echo "<b>no videos found - try again</b><br />";
echo "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"POST\">";
echo "enter your YomanSports user name <input type=\"text\" name=\"username\"><input type=\"Submit\" value=\"search for yomansports videos by this user\">";
echo "</form>";
exit;
}
else {
if($page==1){
echo "Found a total of ".$array->videos["total"]." videos<br />";
}
echo "Page ".$page." of ".ceil($array->videos["total"]/$page_limit)."<br />";
echo "<hr>";
foreach ($array->videos->video as $video){
echo "Title: <b>".$video["title"]."</b><br />";
// display the thumbnail
echo "<img src=".$video["img_src"]."><br clear=\"left\" />";
// original video page url with link
echo "<a href=\"".$video["ind_page_link"]."\">".$video["ind_page_link"]."</a><br clear=\"left\" />";
echo "Description: ".$video["description"]."<br clear=\"left\" />";
echo "Views: ".$video["views"]."<br clear=\"left\" />";
echo "keyword: ".$video["keyword"]."<br clear=\"left\" />";
echo "Add Date: ".$video["add_date"]."<br clear=\"left\" />";
echo "Added By: <a href=\"".$video["profile_link"]."\">".$video["username"]."</a><br clear=\"left\" />";
$params = array(
"api_key" => $api_key,
"method" => "yomansports.video.comment.byVideoID",
"username" => $username,
"video_id" => $video["VID"]
);
$encoded_params = array();
foreach ($params as $k => $v){
$encoded_params[] = urlencode($k)."=".urlencode($v);
}
//$url = "http://api.yomansports.com/services/?".implode("&", $encoded_params);
$url = "http://www.yomansports.com/api/".implode("&", $encoded_params);
if(function_exists("curl_init")){
$detail=curl_init($url);
curl_setopt($detail, CURLOPT_HEADER, false);
curl_setopt($detail, CURLOPT_RETURNTRANSFER, true);
$rsp_comment=curl_exec($detail);
curl_close($detail);
} else {
$rsp_comment = file_get_contents($url);
}
$array_comment = simplexml_load_string($rsp_comment);
if($array_comment->comments["total"] == 0) {
echo "There are no comments for this video<br /><hr>";
}
else {
echo "<ul>";
foreach ($array_comment->comments->comment as $comment){
echo "<li>[".$comment["username"]."] ".$comment["vdo_comment"]."</li>";
}
echo "</ul><br /><hr>";
}
}
}
}
}
?>
<?php
// A simple script to get videos from yomansports by username.
// It uses the yomansports API to get all data from yomansports.
// By using username, it gets video detail from yomansporst
// IMPORTANT: get a yomansports API key from here [ http://www.yomansports.com/my_profile.php ]
$api_key = "Your yomansports API key";
if(!isset($_POST["username"])){
echo "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"POST\">";
echo "enter your YomanSports user name <input type=\"text\" name=\"username\"><input type=\"Submit\" value=\"search for yomansports photos by this user\">";
echo "</form>";
exit;
} else {
getYomanPhotos($_POST["username"]);
}
function getYomanPhotos($username,$page=1,$page_limit = 10) {
global $api_key, $count;
// ######## Get user_id given username
// ######## Build the API request to look up the yoman user_id
$params = array(
"api_key" => $api_key,
"method" => "yomansports.picture.byUserName",
"username" => $username,
"page" => $page,
"page_limit" => $page_limit
);
$encoded_params = array();
foreach ($params as $k => $v){
$encoded_params[] = urlencode($k)."=".urlencode($v);
}
//$url = "http://api.yomansports.com/services/?".implode("&", $encoded_params);
$url = "http://www.yomansports.com/api/".implode("&", $encoded_params);
// As some PHP hosts switch off file_get_contents, here we check to see if curl is installed and use that instead.
if(function_exists("curl_init")){
$detail=curl_init($url);
curl_setopt($detail, CURLOPT_HEADER, false);
curl_setopt($detail, CURLOPT_RETURNTRANSFER, true);
$rsp=curl_exec($detail);
curl_close($detail);
} else {
$rsp = file_get_contents($url);
}
$array = simplexml_load_string($rsp);
if($array["status"] == "fail") {
if($array["error_code"] == 1)
{
echo "<b>The API key passed was not valid or has expired. - try again</b><br />";
}
elseif($array["error_code"] == 2)
{
echo "<b>User name is not valid - try again</b><br />";
}
elseif($array["error_code"] == 3)
{
echo "<b>The requested method was not found - try again</b><br />";
}
echo "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"POST\">";
echo "enter your YomanSports user nam <input type=\"text\" name=\"username\"><input type=\"Submit\" value=\"search for yomansports photos by this user\">";
echo "</form>";
exit;
}
else {
$totalCount = $array->photos["total"];
if($totalCount == 0){
echo "<b>no photos found - try again</b><br />";
echo "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"POST\">";
echo "enter your YomanSports user name <input type=\"text\" name=\"username\"><input type=\"Submit\" value=\"search for yomansports photos by this user\">";
echo "</form>";
exit;
}
else {
if($page==1){
echo "Found a total of ".$array->photos["total"]." photos<br />";
}
echo "Page ".$page." of ".ceil($array->photos["total"]/$page_limit)."<br />";
echo "<hr>";
foreach ($array->photos->photo as $photo){
echo "<b>".$photo["title"]."</b><br />";
// display the thumbnail
echo "<img src=".$photo["img_src"]."><br clear=\"left\" />";
// original photo page url with link
echo "<a href=\"".$photo["ind_page_link"]."\">".$photo["ind_page_link"]."</a><br clear=\"left\" />";
echo "Description: ".$photo["description"]."<br clear=\"left\" />";
echo "Views: ".$photo["views"]."<br clear=\"left\" />";
echo "keyword: ".$photo["keyword"]."<br clear=\"left\" />";
echo "Add Date: ".$photo["add_date"]."<br clear=\"left\" />";
echo "Added By: <a href=\"".$photo["profile_link"]."\">".$photo["username"]."</a><br clear=\"left\" />";
$params = array(
"api_key" => $api_key,
"method" => "yomansports.picture.comment.byPictureID",
"username" => $username,
"picture_id" => $photo["VID"]
);
$encoded_params = array();
foreach ($params as $k => $v){
$encoded_params[] = urlencode($k)."=".urlencode($v);
}
//$url = "http://api.yomansports.com/services/?".implode("&", $encoded_params);
$url = "http://www.yomansports.com/api/".implode("&", $encoded_params);
if(function_exists("curl_init")){
$detail=curl_init($url);
curl_setopt($detail, CURLOPT_HEADER, false);
curl_setopt($detail, CURLOPT_RETURNTRANSFER, true);
$rsp_comment=curl_exec($detail);
curl_close($detail);
} else {
$rsp_comment = file_get_contents($url);
}
$array_comment = simplexml_load_string($rsp_comment);
if($array_comment->comments["total"] == 0) {
echo "There are no comments for this Photo<br /><hr>";
}
else {
echo "<ul>";
foreach ($array_comment->comments->comment as $comment){
echo "<li>[".$comment["username"]."] ".$comment["pic_comment"]."</li>";
}
echo "</ul><br /><hr>";
}
}
}
}
}
?>
<?php
// A simple script to get videos from yomansports by username.
// It uses the yomansports API to get all data from yomansports.
// By using username, it gets video detail from yomansporst
// IMPORTANT: get a yomansports API key from here [ http://www.yomansports.com/my_profile.php ]
$api_key = "Your yomansports API key";
if(!isset($_POST["username"])){
echo "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"POST\">";
echo "enter your YomanSports user name <input type=\"text\" name=\"username\"><input type=\"Submit\" value=\"search for yomansports photos by this user\">";
echo "</form>";
exit;
} else {
getYomanPhotos($_POST["username"]);
}
function getYomanPhotos($username,$page=1,$page_limit = 10) {
global $api_key, $count;
// ######## Get user_id given username
// ######## Build the API request to look up the yoman user_id
$params = array(
"api_key" => $api_key,
"method" => "yomansports.pictures.byChannelName",
"username" => $username,
"page" => $page,
"page_limit" => $page_limit,
"channel_name" => "channel name"
);
$encoded_params = array();
foreach ($params as $k => $v){
$encoded_params[] = urlencode($k)."=".urlencode($v);
}
//$url = "http://api.yomansports.com/services/?".implode("&", $encoded_params);
$url = "http://www.yomansports.com/api/".implode("&", $encoded_params);
// As some PHP hosts switch off file_get_contents, here we check to see if curl is installed and use that instead.
if(function_exists("curl_init")){
$detail=curl_init($url);
curl_setopt($detail, CURLOPT_HEADER, false);
curl_setopt($detail, CURLOPT_RETURNTRANSFER, true);
$rsp=curl_exec($detail);
curl_close($detail);
} else {
$rsp = file_get_contents($url);
}
$array = simplexml_load_string($rsp);
if($array["status"] == "fail") {
if($array["error_code"] == 1)
{
echo "<b>The API key passed was not valid or has expired. - try again</b><br />";
}
elseif($array["error_code"] == 2)
{
echo "<b>User name is not valid - try again</b><br />";
}
elseif($array["error_code"] == 3)
{
echo "<b>The requested method was not found - try again</b><br />";
}
echo "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"POST\">";
echo "enter your YomanSports user nam <input type=\"text\" name=\"username\"><input type=\"Submit\" value=\"search for yomansports photos by this user\">";
echo "</form>";
exit;
}
else {
$totalCount = $array->photos["total"];
if($totalCount == 0){
echo "<b>no photos found - try again</b><br />";
echo "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"POST\">";
echo "enter your YomanSports user name <input type=\"text\" name=\"username\"><input type=\"Submit\" value=\"search for yomansports photos by this user\">";
echo "</form>";
exit;
}
else {
if($page==1){
echo "Found a total of ".$array->photos["total"]." photos<br />";
}
echo "Page ".$page." of ".ceil($array->photos["total"]/$page_limit)."<br />";
echo "<hr>";
foreach ($array->photos->photo as $photo){
echo "<b>".$photo["title"]."</b><br />";
// display the thumbnail
echo "<img src=".$photo["img_src"]."><br clear=\"left\" />";
// original photo page url with link
echo "<a href=\"".$photo["ind_page_link"]."\">".$photo["ind_page_link"]."</a><br clear=\"left\" />";
echo "Description: ".$photo["description"]."<br clear=\"left\" />";
echo "Views: ".$photo["views"]."<br clear=\"left\" />";
echo "keyword: ".$photo["keyword"]."<br clear=\"left\" />";
echo "Add Date: ".$photo["add_date"]."<br clear=\"left\" />";
echo "Added By: <a href=\"".$photo["profile_link"]."\">".$photo["username"]."</a><br clear=\"left\" />";
$params = array(
"api_key" => $api_key,
"method" => "yomansports.picture.comment.byPictureID",
"username" => $username,
"picture_id" => $photo["VID"]
);
$encoded_params = array();
foreach ($params as $k => $v){
$encoded_params[] = urlencode($k)."=".urlencode($v);
}
//$url = "http://api.yomansports.com/services/?".implode("&", $encoded_params);
$url = "http://www.yomansports.com/api/".implode("&", $encoded_params);
if(function_exists("curl_init")){
$detail=curl_init($url);
curl_setopt($detail, CURLOPT_HEADER, false);
curl_setopt($detail, CURLOPT_RETURNTRANSFER, true);
$rsp_comment=curl_exec($detail);
curl_close($detail);
} else {
$rsp_comment = file_get_contents($url);
}
$array_comment = simplexml_load_string($rsp_comment);
if($array_comment->comments["total"] == 0) {
echo "There are no comments for this Photo<br /><hr>";
}
else {
echo "<ul>";
foreach ($array_comment->comments->comment as $comment){
echo "<li>[".$comment["username"]."] ".$comment["pic_comment"]."</li>";
}
echo "</ul><br /><hr>";
}
}
}
}
}
?>
<?php
// A simple script to get videos from yomansports by username.
// It uses the yomansports API to get all data from yomansports.
// By using username, it gets video detail from yomansporst
// IMPORTANT: get a yomansports API key from here [ http://www.yomansports.com/my_profile.php ]
$api_key = "Your yomansports API key";
if(!isset($_POST["username"])){
echo "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"POST\">";
echo "enter your YomanSports user name <input type=\"text\" name=\"username\"><input type=\"Submit\" value=\"search for yomansports videos by this user\">";
echo "</form>";
exit;
} else {
getYomanvideos($_POST["username"]);
}
function getYomanvideos($username,$page=1,$page_limit = 10) {
global $api_key, $count;
// ######## Get user_id given username
// ######## Build the API request to look up the yoman user_id
$params = array(
"api_key" => $api_key,
"method" => "yomansports.training.video.byUserName",
"username" => $username,
"page" => $page,
"page_limit" => $page_limit
);
$encoded_params = array();
foreach ($params as $k => $v){
$encoded_params[] = urlencode($k)."=".urlencode($v);
}
//$url = "http://api.yomansports.com/services/?".implode("&", $encoded_params);
$url = "http://www.yomansports.com/api/".implode("&", $encoded_params);
//echo $url;
// As some PHP hosts switch off file_get_contents, here we check to see if curl is installed and use that instead.
if(function_exists("curl_init")){
$detail=curl_init($url);
curl_setopt($detail, CURLOPT_HEADER, false);
curl_setopt($detail, CURLOPT_RETURNTRANSFER, true);
$rsp=curl_exec($detail);
curl_close($detail);
} else {
$rsp = file_get_contents($url);
}
$array = simplexml_load_string($rsp);
if($array["status"] == "fail") {
if($array["error_code"] == 1)
{
echo "<b>The API key passed was not valid or has expired. - try again</b><br />";
}
elseif($array["error_code"] == 2)
{
echo "<b>User name is not valid - try again</b><br />";
}
elseif($array["error_code"] == 3)
{
echo "<b>The requested method was not found - try again</b><br />";
}
echo "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"POST\">";
echo "enter your YomanSports user nam <input type=\"text\" name=\"username\"><input type=\"Submit\" value=\"search for yomansports videos by this user\">";
echo "</form>";
exit;
}
else {
$totalCount = $array->training_vdos["total"];
if($totalCount == 0){
echo "<b>no videos found - try again</b><br />";
echo "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"POST\">";
echo "enter your YomanSports user name <input type=\"text\" name=\"username\"><input type=\"Submit\" value=\"search for yomansports videos by this user\">";
echo "</form>";
exit;
}
else {
if($page==1){
echo "Found a total of ".$array->training_vdos["total"]." videos<br />";
}
echo "Page ".$page." of ".ceil($array->training_vdos["total"]/$page_limit)."<br />";
echo "<hr>";
foreach ($array->training_vdos->training_video as $training_video){
echo "Title: <b>".$training_video["title"]."</b><br />";
// display the thumbnail
echo "<img src=".$training_video["img_src"]."><br clear=\"left\" />";
// original training_video page url with link
echo "<a href=\"".$training_video["ind_page_link"]."\">".$training_video["ind_page_link"]."</a><br clear=\"left\" />";
echo "Description: ".$training_video["description"]."<br clear=\"left\" />";
echo "Views: ".$training_video["views"]."<br clear=\"left\" />";
echo "keyword: ".$training_video["keyword"]."<br clear=\"left\" />";
echo "Add Date: ".$training_video["add_date"]."<br clear=\"left\" />";
echo "Added By: <a href=\"".$training_video["profile_link"]."\">".$training_video["username"]."</a><br clear=\"left\" />";
$params = array(
"api_key" => $api_key,
"method" => "yomansports.training.video.comment.byVideoID",
"username" => $username,
"training_vdo_id" => $training_video["VID"]
);
$encoded_params = array();
foreach ($params as $k => $v){
$encoded_params[] = urlencode($k)."=".urlencode($v);
}
//$url = "http://api.yomansports.com/services/?".implode("&", $encoded_params);
$url = "http://www.yomansports.com/api/".implode("&", $encoded_params);
if(function_exists("curl_init")){
$detail=curl_init($url);
curl_setopt($detail, CURLOPT_HEADER, false);
curl_setopt($detail, CURLOPT_RETURNTRANSFER, true);
$rsp_comment=curl_exec($detail);
curl_close($detail);
} else {
$rsp_comment = file_get_contents($url);
}
$array_comment = simplexml_load_string($rsp_comment);
if($array_comment->comments["total"] == 0) {
echo "There are no comments for this video<br /><hr>";
}
else {
echo "<ul>";
foreach ($array_comment->comments->comment as $comment){
echo "<li>[".$comment["username"]."] ".$comment["trv_comment"]."</li>";
}
echo "</ul><br /><hr>";
}
}
}
}
}
?>
<?php
// A simple script to get videos from yomansports by username.
// It uses the yomansports API to get all data from yomansports.
// By using username, it gets video detail from yomansporst
// IMPORTANT: get a yomansports API key from here [ http://www.yomansports.com/my_profile.php ]
$api_key = "Your yomansports API key";
if(!isset($_POST["username"])){
echo "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"POST\">";
echo "enter your YomanSports user name <input type=\"text\" name=\"username\"><input type=\"Submit\" value=\"search for yomansports videos by this user\">";
echo "</form>";
exit;
} else {
getYomanvideos($_POST["username"]);
}
function getYomanvideos($username,$page=1,$page_limit = 10) {
global $api_key, $count;
// ######## Get user_id given username
// ######## Build the API request to look up the yoman user_id
$params = array(
"api_key" => $api_key,
"method" => "yomansports.sponsored.training.video.byUserName",
"username" => $username,
"page" => $page,
"page_limit" => $page_limit
);
$encoded_params = array();
foreach ($params as $k => $v){
$encoded_params[] = urlencode($k)."=".urlencode($v);
}
//$url = "http://api.yomansports.com/services/?".implode("&", $encoded_params);
$url = "http://www.yomansports.com/api/".implode("&", $encoded_params);
//echo $url;
// As some PHP hosts switch off file_get_contents, here we check to see if curl is installed and use that instead.
if(function_exists("curl_init")){
$detail=curl_init($url);
curl_setopt($detail, CURLOPT_HEADER, false);
curl_setopt($detail, CURLOPT_RETURNTRANSFER, true);
$rsp=curl_exec($detail);
curl_close($detail);
} else {
$rsp = file_get_contents($url);
}
$array = simplexml_load_string($rsp);
if($array["status"] == "fail") {
if($array["error_code"] == 1)
{
echo "<b>The API key passed was not valid or has expired. - try again</b><br />";
}
elseif($array["error_code"] == 2)
{
echo "<b>User name is not valid - try again</b><br />";
}
elseif($array["error_code"] == 3)
{
echo "<b>The requested method was not found - try again</b><br />";
}
echo "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"POST\">";
echo "enter your YomanSports user nam <input type=\"text\" name=\"username\"><input type=\"Submit\" value=\"search for yomansports videos by this user\">";
echo "</form>";
exit;
}
else {
$totalCount = $array->sponsored_training_vdos["total"];
if($totalCount == 0){
echo "<b>no videos found - try again</b><br />";
echo "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"POST\">";
echo "enter your YomanSports user name <input type=\"text\" name=\"username\"><input type=\"Submit\" value=\"search for yomansports videos by this user\">";
echo "</form>";
exit;
}
else {
if($page==1){
echo "Found a total of ".$array->sponsored_training_vdos["total"]." videos<br />";
}
echo "Page ".$page." of ".ceil($array->sponsored_training_vdos["total"]/$page_limit)."<br />";
echo "<hr>";
foreach ($array->sponsored_training_vdos->sponsored_training_video as $sponsored_training_video){
echo "Title: <b>".$sponsored_training_video["title"]."</b><br />";
// display the thumbnail
echo "<img src=".$sponsored_training_video["img_src"]."><br clear=\"left\" />";
// original sponsored_training_video page url with link
echo "<a href=\"".$sponsored_training_video["ind_page_link"]."\">".$sponsored_training_video["ind_page_link"]."</a><br clear=\"left\" />";
echo "Description: ".$sponsored_training_video["description"]."<br clear=\"left\" />";
echo "Views: ".$sponsored_training_video["views"]."<br clear=\"left\" />";
echo "keyword: ".$sponsored_training_video["keyword"]."<br clear=\"left\" />";
echo "Add Date: ".$sponsored_training_video["add_date"]."<br clear=\"left\" />";
echo "Added By: <a href=\"".$sponsored_training_video["profile_link"]."\">".$sponsored_training_video["username"]."</a><br clear=\"left\" />";
$params = array(
"api_key" => $api_key,
"method" => "yomansports.sponsored.training.video.comment.byVideoID",
"username" => $username,
"training_vdo_id" => $sponsored_training_video["VID"]
);
$encoded_params = array();
foreach ($params as $k => $v){
$encoded_params[] = urlencode($k)."=".urlencode($v);
}
//$url = "http://api.yomansports.com/services/?".implode("&", $encoded_params);
$url = "http://www.yomansports.com/api/".implode("&", $encoded_params);
if(function_exists("curl_init")){
$detail=curl_init($url);
curl_setopt($detail, CURLOPT_HEADER, false);
curl_setopt($detail, CURLOPT_RETURNTRANSFER, true);
$rsp_comment=curl_exec($detail);
curl_close($detail);
} else {
$rsp_comment = file_get_contents($url);
}
$array_comment = simplexml_load_string($rsp_comment);
if($array_comment->comments["total"] == 0) {
echo "There are no comments for this video<br /><hr>";
}
else {
echo "<ul>";
foreach ($array_comment->comments->comment as $comment){
echo "<li>[".$comment["username"]."] ".$comment["trv_comment"]."</li>";
}
echo "</ul><br /><hr>";
}
}
}
}
}
?>