SoundCloud - Update Cover / Artwork Image - php

We use the SoundCloud API to upload tracks with PHP. This is all working perfectly, but we would like to be able to update the track cover artwork with the SoundCloud API. We already upload the cover art when we initially upload the track, but when we try and modify it after the initial upload, it doesn't seem to work (we don't get any errors, it just doesn't get updated and stays the same as it was before).
Is this an intentional limitation of the SoundCloud API or am I missing something?
Edit 1:
I've emailed the SoundCloud API team to ask if they'd just clarify if updating track artwork is possible via the API, but I've had no response (around 48 hours so far).
Edit 2 - 2014-07-08:
4 days on and still no reply yet from the SoundCloud API team? Am I being ignorant thinking this is a simple "yes it should work" or "no that isn't supported with the current API" reply?
Edit 3 - 2014-08-28:
Over 7 weeks and still haven't heard anything from SoundCloud. Looks like they aren't going to be replying!
$track_info_array = array(
'track[title]' => $track['title'],
'track[sharing]' => $track['sharing'],
'track[track_type]' => $track['track_type'],
'track[purchase_url]' => $track['purchase_url'],
'track[description]' => $track['description'],
'track[genre]' => $track['genre'],
'track[label_name]' => $track['label_name'],
'track[tag_list]' => $track['tag_list'],
'track[release_day]' => $release_date[2],
'track[release_month]' => $release_date[1],
'track[release_year]' => $release_date[0],
'track[isrc]' => $track['isrc'],
'track[release]' => $track['release'],
'track[bpm]' => $track['bpm'],
'track[key_signature]' => $track['key_signature']
);
if($release_image){
$track_info_array['track[artwork_data]'] = '#'.$release_image;
}
$track_info = $soundcloud->put('tracks/' . $track['soundcloud_track_id'], $track_info_array);

If it's possible, I believe you want to use PUT instead of a POST request. you also will want to include the track's ID in the endpoint.

Acording to the docs, it is only possible to use artwork_data for uploading, no updates to the audio file nor the artwork.
The fields artwork_data and asset_data have a comment of "only for uploading"
Reference: https://developers.soundcloud.com/docs/api/reference#tracks

Delete all your temporary internet and cache files. It may actually be changing for everyone else but you.

There is a trick that usually works. The Soundcloud API may have some sloppy coding. Try editing the entire URL link for the target file. That should work.

Related

Add hashtags to twitter api status update

Been trying to figure out the array for a while now but I can't get a hashtag posted with the tweet, the tweet itself is posting just fine, just not with the hashtag, my code is below:
$tweetmsg='testing'; //this is just an example of the variable
$connection->post('statuses/update',array('status' => $tweetmsg, 'entitites' => array('hashtags' => array('text' => 'test'))));
Docs: https://dev.twitter.com/rest/reference/post/statuses/update
API library i'm using: https://github.com/abraham/twitteroauth
You just use:
$tweetmsg='testing #one #two #three';
And it should work, unless you are changing # into an html entity or stripping it.
Edit:
As a tip, I'll tell you that it might be easier to use https://github.com/jublonet/codebird-php instead of your library.

Image not appearing when publishing to stream

I'm writing a PHP app that posts to users' feeds. The posts are showing up in the feeds, but the images I'm specifying aren't.
App is currently in sandbox mode, so not sure if that makes a difference.
Here is the data array I'm passing:
$data = array(
'message' => 'I just donated to ORGANIZATION to help end the needless killing of healthy animals.',
'name' => 'Each day over 10,000 healthy pets are killed. Together we can help change this.',
'caption' => 'petbucks.net',
'link' => 'http://petbucks.net',
'description' => 'Sponsorship of real homeless pets gives them the time they need to find a forever home.',
'picture' => 'http://dev.petbucks.net/img/default-donation.jpg',
'actions' => array(
array(
'name' => 'Visit us',
'link' => 'http://petbucks.net'
)
)
);
Facebook::api('/'.$uid.'/feed', 'post', $data);
Like I said, the post is appearing in the user's feed, but the picture isn't. If I inspect the source of where the URL should be, here is the image tag that appears:
<img class="shareMediaPhoto fbStoryAttachmentImage img" src="https://fbstatic-a.akamaihd.net/rsrc.php/v2/y4/r/-PAXP-deijE.gif" alt="" style="background-image: url(https://fbexternal-a.akamaihd.net/app_full_proxy.php?app=332280520247212&v=1&size=z&cksum=534f379420f4d890f47eebaa5bf15f4a&src=http%3A%2F%2Fdev.petbucks.net%2Fimg%2Fdefault-donation.jpg);">
Based on that, I'd say that it's receiving the picture URL just fine (you can see the real URL in the source of that background image), so it must be something else. Is it because of sandbox mode?
Any idea what's going on would be appreciated!
Update
There was some weird DNS issues going on, so those have been fixed. However, I am now seeing full-size images in my main news feed, but not smaller ones in my own newsfeed.
This is going to be hard to demonstrate without giving out access to my FB account, but as an example, take a look at this post which I've made public:
https://www.facebook.com/colin.viebrock/posts/10153814802000226?stream_ref=10
That image shows correctly for me when I'm logged into FB, but not for you I'm guessing. The URL it is trying to display is:
https://fbexternal-a.akamaihd.net/app_full_proxy.php?app=332280520247212&v=1&size=z&cksum=15a4249f3c830d8818ed66e793ba3156&src=https%3A%2F%2Fpetbucks.org%2Fimg%2Fdefault-donation.jpg
When it does show up, it's referencing this image:
https://fbexternal-a.akamaihd.net/safe_image.php?d=AQD1l81SkouNC200&w=154&h=154&url=https%3A%2F%2Fpetbucks.org%2Fimg%2Fdefault-donation.jpg&cfs=1&upscale

Retrieving Posts from Tumblr

I've tried to do my research regarding this topic but the more digging I do, the more confused I'm getting - seems like the documentation on Tumblr's API is all over the place (and fairly dated?); so perhaps someone out there will have some advice for me.
All I'm trying to do is to snag my most recent Tumblr posts and display them on the main page of my website; nothing too fancy. I don't need to POST to tumblr, I just need the info; the idea is that the team I'm working with would like to use Tumblr as a sort of poor-man's CMS while maintaining their presence on the Tumblr site proper.
I can easily retrieve posts using PHP and SimpleXML (http://username.tumblr.com/api/read) - but this doesn't offer too much support outside simple text posts (Other content, like video, photosets, etc - post differently); and it doesn't really seem like an officially supported method of accessing tumblr data (or..maybe it is?). Tumblr itself points folks towards tumblr.php, but I for the life of me can't figure out how to set it up since there's no real documentation for someone just starting to dabble. Some posts on StackOverflow say Tumblr.php doesn't work anymore and point folks to tumblrOauth.php, but I'm running into the same problem. No real 'new to API' documentation. I know how to set up my 'app' in Tumblr - I just don't know how all the Github files (for both of these systems) communicate to each other/the page...
Anyone have any advice? I'm just looking for a point in the right direction, maybe an initial nudge on how to hook the bits up?
Much thanks e-friends!
Hey I've used a few API's but not the Tumblr API, after reading through this page: http://www.tumblr.com/docs/en/api/v2 I'm pretty sure I understand how to set this up so I'll have a go at explaining and you can let me know if you have some success
(Removed code, that PHP API is awful)
EDIT: Original edit removed
Right since the Tumblr PHP Client is rubbish I've had a look myself and just designed a little snippet of code to solve the problem here and retrieve your latest posts in an array that will give you like so:
Array
(
[0] => Array
(
[id] => 49867777007
[type] => photo
[description] =>
[date] => 2013-05-07 18:28:41 GMT
[short_url] => http://tmblr.co/Z5XfMxkSMUFl
[caption] =>
[photo_url] => http://31.media.tumblr.com/a13494fb3cda1e40ab39211973a094f9/tumblr_mm0038sZGH1qdlh1io1_400.gif
[width] => 395
[height] => 350
)
Use this code and then go through your $myposts later on the page
<?php
$apikey = "your_api_key";
$limit = 10;
$tumblr = "your.tumblr.com";
$apidata = json_decode(file_get_contents("http://api.tumblr.com/v2/blog/$tumblr/posts?api_key=$apikey&limit=$limit"));
$mypostsdata = $apidata->response->posts;
$myposts = array();
$i = 0;
foreach($mypostsdata as $postdata) {
$post['id'] = $postdata->id;
$post['type'] = $postdata->type;
$post['description'] = $postdata->description;
$post['date'] = $postdata->date;
$post['short_url'] = $postdata->short_url;
$post['caption'] = $postdata->caption;
$post["photo_url"] = $postdata->photos[0]->original_size->url;
$post["width"] = $postdata->photos[0]->original_size->width;
$post["height"] = $postdata->photos[0]->original_size->height;
$myposts[$i] = $post;
$i++;
}
// Then handle $myposts later on your page
echo '<pre>'.print_r($myposts).'</pre>';
// There's quite a lot more data you can use so if you want
// to print out $mypostsdata then you might find any more data you need
?>
Sorry the previous suggestions didn't work, the PHP Client really is awful but let me know if that's enough or if you need some revision to it

Facebook Graph API Change: Picture type (size) no longer working?

According to Facebook's Graph API documentation (here), you can access various sizes of a user's profile picture through URLs such as:
https://graph.facebook.com/(userid)/picture?type=small
https://graph.facebook.com/(userid)/picture?type=large
You'll notice that the first resolves to a url ending in _t.jpg (the small thumbnail) and the second ending in _n.jpg (the large image). So far so good. Equivalently, we should be able to query for these images like this:
https://graph.facebook.com/(userid)?fields=picture&type=small
https://graph.facebook.com/(userid)?fields=picture&type=large
This latter format worked as expected for many months, until just a few days ago when it suddenly started ignoring the "type" parameter entirely - everything now resolves to an image ending in _q.jpg, which is the default if no "type" is specified. As a result, I can no longer figure out a way to query for the large image in PHP (my real problem). It used to work like this:
$pic = $facebook->api('/me', array('fields' => 'picture', 'type' => 'large'));
...but as described above, "type" has spontaneously started being ignored. I've spent several hours scouring their documentation but haven't been able to find any reference to what has changed, or the "new" way this should be done - any pointers would be hugely appreciated...
EDIT:
None of the following work, either (returns nothing):
$pic = $facebook->api('/me/picture', array('type' => 'large'));
$pic = $facebook->api('/(my_uid)/picture', array('type' => 'large'));
$pic = $facebook->api('/me/picture/?type=large');
$pic = $facebook->api('/(my_uid)/picture/?type=large');
Basically, since Facebook broke things a few days ago there doesn't seem to be any way to get a non-default picture size from PHP. You can try out some of the calls yourself from the Graph API Explorer (here).
Other related/relevant links:
http://stackoverflow.com/questions/2978761/facebook-graph-api-will-not-give-me-picture-data
http://stackoverflow.com/questions/7718704/requesting-picture-for-event
You must request the API with the field_expansion syntax
These api requests works :
$results = $facebook->api('/me', array('fields' => 'picture.height(300).width(300)'));
$results = $facebook->api('/me', array('fields' => 'picture.type(large)'));
As described in this bug on Facebook, you can request this via the new API "field expansion" syntax.
This works for me:
https://graph.facebook.com/____OBJECT_ID____?fields=picture.type(large)
I found a workaround - profile pictures of various sizes can still be accessed via an FQL query:
$pic = $facebook->api(array('method'=>'fql.query', 'query'=>"SELECT pic_big FROM user WHERE uid=$fb_uid"));
("pic_big" is equivalent to "type=large" - see here).
This still doesn't explain why the GRAPH call suddenly broke though, or why image sizes don't seem to be accessible via Graph at all anymore (which I'd still like to know)...but at least there's some way to get the other size photos.
Gotta love Facebook and their top-notch reliability...

Tagging photos on Facebook with Graph API / PHP SDK

The question is pretty much in the title, but to be more specific, I'm working on a facebook contest for a client in which people have to upload photos to take part in it after accepting rules and subscribing, etc.
After going down a long road full of deceptions
(here's what I tried that didn't work in the end:
uploading to the user's album then tagging the page: nope, can't tag a page
uploading to a public album in the page, like "fan photos", or wall photos? can't find anything AT ALL about a way to do this, though it would've been my preferred way.)
So, I ended up having an idea: I would do this in two steps. First, the user subsribes and uploads a photo to my PHP server. Then, another, different application with permissions on the account that has the page, would take control of it, upload all the photos at 5 minutes intervals (meaning, you subsribe, 5 minutes later, your photo's uploaded.)
So far, so good; I don't like the logic behind this, but it's the only way I found! So, I did the base, I'm able to post a photo with a caption as the page in a dedicated app album.
BUT! I can't tag anyone in those photos. Maybe you can't tag as a page, maybe you can't tag in page albums, maybe I don't have the permissions required (I have stream_publish, user_photos, friends_photos, offline_access, and I could add anything if I need to since it's a private-use app anyway). Oh and, the user I'm trying to tag is the admin for both the app and the page (and he likes the page). I don't know, but it's driving me crazy. I hate the official documentation, there's no example code, you have to figure out most of the things, go through trial and error or search on the web for people who did so and shared how to do things. Not nice when you have little time to complete a project for a client without busting the budget.
Anyway, here's my error I keep getting whenever I try to tag someone to a photo from any album:
OAuthException: (#322) Invalid photo tag subject
And here's the code I'm using to upload a photo from the server to facebook.
if ($user) {
try {
$page_info = $facebook->api("/$page_id?fields=access_token");
if( !empty($page_info['access_token']) ) {
// First method, at the same time as upload. Upload works but no tags
$args = array(
'access_token' => $page_info['access_token'],
'source' => '#' . realpath($FILE_PATH),
'message' => "test"
'tags' => array(
array(
'tag_uid'=> "MY_USER_ID",
'x' => 0,
'y' => 0
))
);
$post = $facebook->api("/$page_id/photos","post",$args);
$postID = $post['id'];
// Second method I'm trying. No tags.
$tag = $facebook->api("/$postID/tags/MY_USER_ID","post");
print_r($tag);
}
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
Any help would be appreciated. Thanks in advance!
EDIT :: Now I got it partly working using the second part in the code, but only if I remove the "access_token" parameter from the photo posting first. Basically, it only works if I upload it to a personal album. But that's as far as it gets from what I want. When I upload it to the album from the page, it says I asked for tag requests, but on my personal account which I tagged, I don't receive anything. Baaaah.
RE-EDIT :: After much tries, it seems I can't tag someone as a page or in a page album. I'll try to find an alternative, I guess.

Categories