Problems uploading images with "Share on LinkedIn" - linkedin-api

So I am trying to post an image to my personal page through the new v2 LinkedIn API. I am sending the following data:
{"author":"urn:li:person:MYID","lifecycleState":"PUBLISHED","visibility":{"com.linkedin.ugc.MemberNetworkVisibility":"PUBLIC"},"specificContent":{"com.linkedin.ugc.ShareContent":{"shareMediaCategory":"IMAGE","shareCommentary":{"text":"Hello. Just testing the LinkedIn API."},"media":[{"status":"READY","originalUrl":"https:\/\/www.bbc.co.uk\/news","title":{"text":"BBC news"},"description":{"text":"A test post about BBC news"},"media":"urn:li:digitalmediaAsset:C4E22AQFmydgog-wKTw"}]}}}
As you'll see I've already uploaded the image and have a successful Asset ID and reference.
I get a successful id back from Linkedin: urn:li:share:651159824176993XXX but for some reason my image never appears?? What am I doing wrong?

Before creating the UGC post referencing the registered asset, you need to make sure that the asset is AVAILABLE, otherwise your image won't appear on LinkedIn.
When registering an asset, it goes through the following phases:
PROCESSING (LinkedIn probably does some optimizations to the image / checks if it's valid)
AVAILABLE (you should be good to go)
CLIENT_ERROR (or some other error I can't remember. Basically you should try it with a different asset)
For my app, before creating the UGC post with the image(s), I make sure the asset(s) is / are AVAILABLE first. How do I do that? By checking the status of each asset every 5 seconds with a timeout of 5 minutes (I tried it with a GIF once and to this day is still processing haha).
Once all assets are AVAILABLE, I create the UGC post referencing them, just like you did in your question.

Related

Facebook API Private Message image expired - How to get new image ? URL signature expired

I'm helping maintain an app that integrates with Facebook, and has lots of archived links to old private message images. Sometimes these images expire, and we go to facebook and request a new image. This works 90% of the time.
About 10% of the time we're getting back a response that we can't tell what the new image is.
What's the proper way to request a new url for an expired Facebook Private Message image, preferably using v2.5 or newer of the Graph API?
Currently we're doing a GET request to Facebook's Graph API using the message id of the private message like so:
https://graph.facebook.com/v2.3/m_mid.XXXXXXXXX:YYYYYYYYY
and that gives us a response that has a bunch of attachments in it. For 90% of use cases, there's a new attachment that has an url or name field with a new filename that contains the old filename, e.g. old file name being XXX, we'd see a new filename like ....XXXX.... in the url field.
attachments [url='*%s*']/image_data/url
attachments [name='*%s*']/image_data/url
or sometimes
picture
but that doesnt match what we get now, which is a bunch of attachments with no way to map to the new image.
We haven't been able to find a graph API way of doing this, but have the following solutions we're considering:
When there's only one attachment in the response, we just use that one url. This works some of the time, but fails when there's more than one image of course
Save more metadata about the image, at worst case an MD5 of the file. Then compare that to MD5's of the other files until we get the one we want. Instead of an MD5, we could consider using info about the file from a HEAD request. All of this is untested.
Update our old message metadata with new metadata whenever this happens, thus avoiding the problem entirely as new image requests would come from the new metadata.

Facebook, post to wall, using me/photos, in 2.1 Facebook?

Considering a Unity project from ~3 years ago, and using Facebook graph I'm pretty sure it was 1.0,
You could post to a user's wall like this:
private byte[] imageAsBytes;
Texture2D im = ... your image
imageAsBytes = im.EncodeToPNG();
Dictionary<string, object> dct = new Dictionary<string, object>
{
{ "message", "Marketing message here" },
{ "picture", imageAsBytes }
};
Facebook.instance.graphRequest(
"me/photos", HTTPVerb.POST, dct, completionHandler );
As has been made known for many months now, there is a change to this coming.
With Facebook 2.1 being required as of this Aug 8, I'm rather confused about, simply, whether this still works in 2.1?
in short, how to post an image to the user's wall, in 2.1?
Note - here's where to find the important resource CBRoe mentions below...
Note that the only problem with the alternative, FB.FeedShare() is that, as far as I understand, you can not actually post an image (sure, you can link to an image at a URL).
This isn’t deprecated in any way. But since API v2.0 you need to get the necessary permission reviewed and approved by Facebook, before you can ask normal users for it.
And yes, this is a rather major change - but that's why it was announced way ahead of time, via a lot of channels. We all know how fast the IT world moves and changes- so I think you can not put the blame on Facebook here. If you were "out of the game" (this particular one) for over three years, you just have to go and find the resources that a) list what's changed, and b) what the current state of things is. And the developer section does both. The changelog has already been mentioned, and for example the need to get permissions reviewed now is also mentioned on the starting page for Facebook login, right at the top under Essential Guides.
Plus, Facebook actively informs you about changes - if you let them. Go to https://developers.facebook.com/settings/developer/contact/ where you'll find several options to get informed about specific stuff via e-mail.
You can check the changelog to see what changes happened https://developers.facebook.com/docs/apps/changelog. There are no changes for /me/photos as far as I can tell.
It is possible to use image data or a URL.
See https://developers.facebook.com/docs/graph-api/reference/user/photos#Creating for more info

In the Soundcloud API, is information about a track still available after it's removed due to DMCA infringement?

I'm building an app that utilizes Soundcloud API and we came across a small problem. We archive playlists on our own servers to cut down on the amount of data needed to display tracks. So, for example, a user can create a playlist with tracks from soundcloud but we strip away the data provided by soundcloud to the minimum required to view and play said track. This data includes it's SC_ID, track name, artist, stream URL, etc. But doesn't provide the full data set SC does.
My question:
When songs are removed due to DMCA Copyright infringement, does SoundCloud keep the track ID and information available or does it remove the track entirely? What I mean by this is, say I have a track with ID 123456 and it was removed due to DMCA. Does this track still exist such that I could GET request [SC_api_url]/tracks/123456.json which would yield the track but it would not be streamable nor downloadable?
Correct my logic if I am wrong. I've searched the documentation and the best answer I can get is if you try and request a resource that is not available it throws a common 404 error but the API is not very clear on what happens when tracks are removed due to DMCA violations.
So I reached out to Soundcloud and they said that they are removed from the public facing API.
This means an error would occur if you referenced it.
This is also true for exceeding quotas.
Hope this also helps someone else too!

Google Drive Sdk- Audio & Video Streaming in iOS Application

Hi Google Drive Staff,
I have tried to stream video files from Google Drive(Without Downloading). But I gets alerts that Sign In. I have went thoroughly with Dr. Edit sample App but i did not found any solution. I tried with downloadUrl , embedLink, webContentLink, alternateLink. All gives message to sign In. When i tried with exportsLinks i get a Null Message. What is the problem Here. If U have any suggestion Please Let me Know...
I have tried with Google Drive for iOS in iPod, there we can stream Video without Downloading.
Please suggest me to resolve this issue
Thanks in Advance...
I could solve it just by appending the access_token to the download url
audiofile.strPath=[NSString stringWithFormat#"%#&access_token=%#",downloadUrl,accessToken];
pass the strPath to your avplayer object to play music.
I did not try the video part. but i think a similar approach should work.
you can fetch the access token from the GTMOAuth2Authentication object
Note that you might need to refresh it if its expires.
Hope this helps you.
Regards
Nitesh
I think it depends what you mean by "stream". Last time I looked, the download links all had a content disposition: attachment header, which instructs the browser to download rather than render the content.
If you have your own client fetching the url, you can choose to ignore that header and do what you like with the content as it is fetched. imho, it would be nice if the client could add a parameter to the url to indicate to the Google servers that it wants the content to be rendered v. downloaded, but hey ho.
You need to authorize all requests to downloadLinks with an Authorization header. Read more about the authorization and learn how to retrieve your users an access token on https://developers.google.com/drive/about-auth

facebook An access token is required to request this resource

I am using facebook app to upload videos to user walls.
Note:
I have user permission for publish.
Script is fine and works for small videos with success.
I have user extended token with validity 60 days and I debugged my token and its fine with validity and have posting permissions.
my script for posting is working fine with small videos.
ISSUE
When I try to upload more than 100 MB video with only 5 or 6 min length I receive following api errors.
An access token is required to request this resource.
An active access token must be used to query information about the current user.
NOTE
When I apply small videos it works successfully.
TEST
I added same video with same length with two different sizes one is 720P with ~121MB and other is 480P with ~42MB both are same video.
But 480P with ~42MB uploaded successfully and 720P with ~121MB failed and api throws this exactly error in error log
An access token is required to request this resource.
$facebook->setAccessToken($access_token);
$facebook->setFileUploadSupport(true);
$data = $facebook->api('/'.$user_id.'/videos', 'post', $args);
The issue was resolved.
We placed this as a bug in facebook bug.
We used the code provided by Facebook support team and issue was resolved.
Facebook support response:
"We were not able to replicate this issue.
If you are still experiencing issues, can you setup a testbench on your server and run the below example to verify your implementation? If you can provide a link to the testbench with the modified code below, that would be helpful in replicating this issue.
Main code:
https://github.com/eosgood/fbphpsdk
Modification for video post:
https://gist.github.com/anonymous/6872121
We tested this on our servers with a 177MB MKV video without any failures."