I'm trying to use the SoundCloud API to check if a song is embeddable, is this the same as streamable? My code looks like this:
$trackid = $track['id'];
$username = mysql_real_escape_string($track['user']['username']);
$title = mysql_real_escape_string($track['title']);
$downloadable = $track['downloadable'];
$streamable = $track['streamable'];
// Check if streamable
if(!$streamable) {
header( 'Location: error.php' );
} else { ...
I can get the trackid, username, title & downloadable easily, but is streamable the correct property to look for? I'm talking about when you go to embed a song and it says "Oops this track can't be played outside of SoundCloud." I want to make sure this doesn't happen and unallow a song if it's one of those songs.
Referring to the documentation the streamable proprety exists. And yes it's the right one.
Related
I need to make an PHP application where anybody can define a page name and get the public information of that page, specifically the followers count.
For example, Google's Facebook page (https://www.facebook.com/Google/) has 28.318.253 likes and 33.390.596 followers. How can I, programatically, get those numbers?
I want my final code to look something like this:
$page = "google";
// Some code logic, API calls or anything else
$likes = $pageData->likes_count;
$followers = $pageData->followers_count;
echo $likes; // Should output "28318253"
echo $followers; // Should output "33390596"
I want to run/execute jquery code on facebook, twitter, google plus iframe.
I have tried to do it in many ways but it is not working.
Code is always showing error none/object not found.
Actually I want to know whether currently logged-in user has already done like/follow/+ .
If the current logged-in user has already done like/follow then I need to hide like/follow links,
If you are using the PHP Facebook SDK you can query it as follows:
$likes = $facebook->api('me/likes');
$fanpageliked = false;
$appliked = false;
foreach ($likes['data'] as $ilike) {
if ($ilike['id'] == $fanpageid) {$fanpageliked = true;}
if ($ilike['id'] == $appid) {$appliked = true; }
}
If your fanpage id is stored in $fanpageid, or app id in $appid, then $fanpageliked will be true (and/or appid).
So if you are only looking for a fanpage id, remove the appid if and add a break:
if ($ilike['id'] == $fanpageid) {
$fanpageliked = true;
break;
}
After that, you can have the following:
if (!$fanpageliked) {
echo "Like us NOW!";
// .... display like button etc
}
else {
echo "You are ours now. Bwa ha ha!";
}
You can't do that with jquery but you can use their own APIs to accomplish what you need. Facebook for example already has all that in their API.
Error am getting OAuthException: (#100) picture URL is not properly formatted
I have got a very strange problem,I am able to upload pictures on my page album using graph api,but when i try to post a picture using graph api,it is not working,
Note when i post a message or a link to wall,its getting posted,the problem is only with the picture.
Here i am putting both the code snippets:
1,This is when i am trying to upload a picture to page album(working):
$facebook->setFileUploadSupport("http://apps.facebook.com/pagecron");
$x=realpath($_FILES['source']['tmp_name']);
$parameters = array('message' => $_POST['message'],'source' =>'#' . $x );
$parameters['access_token'] = $_SESSION['active']['access_token'];
$check=$facebook->api('/'.$_SESSION['active']['id'].'/photos/','POST',$parameters);
2,This is when i am trying to post a picture to the wall(Not Working):
$img = realpath($y);
$facebook->setFileUploadSupport("http://apps.facebook.com/pagecron");
$x=realpath($_FILES['source']['tmp_name']);
$parameters = array('message' => $_POST['message'],'picture' =>'#' . $x );
$parameters['access_token'] = $_SESSION['active']['access_token'];
$check=$facebook->api('/'.$_SESSION['active']['id'].'/feed/','POST',$parameters);
Ist Thing: You need to POST to /TIMELINE_PHOTOS_ALBUM_ID/photos.
2nd Thing:There may not be an album with such a name,so you should ist create it(After checking).
How To:
$albums =$facebook->api('pageid/albums',GET,array('access_token'=>'access_token');
foreach($albums['data'] as $album)
{
if($album['name'] == 'TIMELINE_PHOTOS')
{
$uid = $album['id'];
}
}
if(isset($uid) && $uid !=0)
{
//mean album is there so use that uid to post your photo
}
else
{
//create your album with that name and use its id
}
It appears that if you want to post a photo to a user's wall, you need to POST to /TIMELINE_PHOTOS_ALBUM_ID/photos.
There doesn't appear to be a shortcut here to get at this. You need to search through the results of /USER_ID/albums to find the album_id of album named "Timeline Photos" (or get it using FQL).
The documentation says that albums have a limit of 200 photos. I'm not sure what happens if a user has more than 200 photos in their "Timeline Photos" album. I couldn't find a friend to inspect this against.
I ran into a small problem what i cant really solve.
I created a delete function for videos in fuel php with orm, and maybe its a but stupid but i cant really figure out how to redirext the user if and id doest not exsits.
here is my code
public function action_delete($id)
{
$deletevideo = Model_Video::find($id);
if($deletevideo->user_id != Session::get('sentry_user')):
Session::set_flash('fail', 'The video you want to remove is not yours, we logged this activity');
Response::redirect(Uri::base() . "myvideos");
else:
unlink(realpath("users/video/" . $deletevideo->video_preview));
unlink(realpath("users/video/" . $deletevideo->video_file));
$deletevideo->delete();
Response::redirect(Uri::base() . "myvideos");
endif;
}
html
Delete
I saw in a forum people talked about DB::expr to achive this but can find any example about it.
Could please someone give me a hint?
Here is some code that should get you going:
$video = Model_Video::find($id);
if ( ! $video instanceof Model_Video)
{
Session::set_flash('fail', 'The video ID is not valid!');
Response::redirect('go/somewhere/else');
}
You should always check if the result is in fact a valid Model_Video before using it.
I searched Google and Stackoverflow but could not find the answer. Probably it is because I am searching for the wrong question. Without the right question, it’s hard to get the right answers. So I hope someone can help me.
I have created a top 20 list where people can rank their favourite website (I know it is not that original, but I do it to learn php)
Websites can be added to a database and are sorted based on votes. Each website has its own unique ID in the database, name and position.
What I cannot figure out is how to do the following.
Next to the list displayed show a get code button. This button will create a code for an image file that can be display on any website. For example:
<img src="http://www.example.com/counter.php?id=47"/>
or even better
<img src="http://www.example.com/47.gif"/>
To do this I need to make a php code, that can take the id and turn it into a nice image file and there I am stuck. I have seen twitter, feedburner, Technorati and over 100 other websites do this, but I cannot find out how.
I found this code that fakes feedburner, but I cannot figure out how to turn it into what I need.
<?php
//Send a generated image to the browser
create_image();
exit();
function create_image(){
//Create the image resource
$image = imagecreatefromgif('image.gif');
//Create text color
$brown = ImageColorAllocate($image, 0, 0, 0);
//Check for the get parameters
if (isset($_GET['count']) && is_numeric($_GET['count']))
$rank = $_GET['count'];
else
$rank = 20;
// Some Alignment Calculations
$bbox = imagettfbbox(8.5, 1,'verdana.ttf', $rank);
$xcorr = 0 + $bbox[2]; $xcorr = 31 - $xcorr;
//Add the number in brown color to the image
imagettftext($image,8.5,0,$xcorr,16,$brown,'verdana.ttf',$rank);
//Tell the browser what kind of file is come in
header("Content-Type: image/gif");
imagegif($image);
//Free up resources
ImageDestroy($image);}?>
Based on
www.mygeekpal.com/how-to-fake-your-feedburner-subscribers/
Using the above code and naming it counter.php I can fetch the position from the database and create
<img src='http://www.example.com/counter.php?count=".$array ['position']."' />
This takes the positon of a website from the database ($array has already been made to fetch) and creates an image with the position nr.
Works fine, but once the postion changes based on user ratings, the image will not show the correct data.
I hope someone can help. Thank you.
Summery
Basically what I am try to make is something that will show the most recent data, based on the ranking of the website. Just like showing the number of twitter followers, for example http://twittercounter.com/counter/?username=labnol or feedburner followers on http://feeds.feedburner.com/~fc/labnol
Both are images that show a number based on information in a database. But I want to create my own image, based on the rank of the website in the database.
Looking at your code it should update everytime the page is reloaded. Clear your browser cache.
If this fails i would check from where it is getting the Get['count'] data which im assuming is the Rank number of the site.
Can you check that the Get['Count'] data is updating as it should ?
Im not sure using an ARRAY in the URL is a good idea, why not use Sessions ?
This link might be of interest.
Sorry i have not been of more help.
This is what I have so far (I cannot edit this question from this computer, due to different cookies).
This is based on the help from
How to fetch data from database and display it in PHP?
thanks to
https://stackoverflow.com/users/353790/robertpitt
This seems to work
<?php
//Connect to DB
$db = mysql_connect("localhst","user","pass") or die("Database Error");
mysql_select_db("db_name",$db);
//Get ID from request
$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
//Check id is valid
if($id > 0)
{
//Query the DB
$resource = mysql_query("SELECT * FROM domains WHERE id = " . $id);
if($resource === false)
{
die("Database Error");
}
if(mysql_num_rows($resource) == 0)
{
die("No User Exists");
}
$user = mysql_fetch_assoc($resource);
}
$img_number = imagecreate(110,24);
$image = imagecreatefromgif('image.gif');
$backcolor = imagecolorallocate($img_number,254,46,212);
$textcolor = imagecolorallocate($image, 0, 0, 0);
imagefill($image,0,0,$backcolor);
$number = $user['position'];
Imagestring($image,9,26,4,$number,$textcolor);
header("Content-Type: image/gif");
imagegif($image);
ImageDestroy($image);
?>