Finding Facebook ID from URL - url

In Facebook's documentation it says you can find the ID from a URL, and that used to be the case. It doesn't appear to be true anymore.
This example is straight from Facebook's API Documentation:
--------------FACEBOOK DOCS---------------------
The "ids" query parameter also accepts URLs. This is useful for finding IDs of URLs in the Open Graph. For example: https://graph.facebook.com/?ids=http://www.imdb.com/title/tt0117500/
But when you click on that link it gives you:
{
"http://www.imdb.com/title/tt0117500/": {
"id": "http://www.imdb.com/title/tt0117500/",
"shares": 18226,
"comments": 7
}
}
Which does NOT include the real Facebook ID for this example URL. If I go to the debugger and enter this URL I can find the ID, which is: 380728101301
So how can I find the ID without using the Open Graph Debugger? I need to be able to get IDs through the code on my site, and can't manually visit the debugger every time.. anyone know how to do this now?
Thanks very much!

There is one possibility with FQL:
SELECT url,site,id FROM object_url WHERE url = 'http://www.imdb.com/title/tt0117500';
https://developers.facebook.com/docs/reference/fql/

Related

How to get the iOS app Apple ID from a Bundle ID?

If I have the Bundle ID of an app, is it possible to programmatically get the Apple ID? eg. the xxx part in this url: http://itunes.apple.com/lookup?id=xxx
Using the lookup url above, it is possible to do the reverse: get the bundle id given an app's apple id.
I'm ultimately looking to programmatically get the icon of an app, but I only know the Bundle ID of the apps. any help is appreciated.
This is actually remarkably easy and can be done programatically by simply changing the parameter of my original query from 'id' to 'bundleID'
eg. http://itunes.apple.com/lookup?bundleId=xxx
The response will be a JSON object with the results that will include the thumbnail url among other things. eg.
{
"resultCount":1,
"results": [
{
"screenshotUrls":[...],
"ipadScreenshotUrls":[...],
"artworkUrl512":"...",
"artistViewUrl":"...",
"artworkUrl60":"...",
"artworkUrl100":"...",
...
}
]
}

Accessing public Instagram content via Instagram API without expiring accesstoken

i want to show public contents from instagram related to a specific hashtag (everything works fine with that) but i can't to renew the access_token everytime it expires.
("do not assume your access_token is valid forever." -
https://www.instagram.com/developer/authentication/)
To renew it manually is not an option i have to make sure there is a valid access_token at ANY time without re-authenticating.
Any ideas or questions? :)
I have one idea, but without API (and access_token). You can make requests to the web-version of Instagram with ?__a=1 parameter. I do not know how long it will work but now there is workflow:
You want to show public content with hashtag space, for example.
Add it to url and add GET-parameter ?__a=1: https://www.instagram.com/explore/tags/space/?__a=1
Make the GET-request. It returns json with nodes in top_posts (8) and media (18). Each node has owner, caption, number of comments and likes. But the most important part is in thumbnail_src and display_src.
There is page_info in media object which helps to paginate results. You need end_cursor (for example, J0HWE9rjAAAAF0HWE9qvgAAAFiYA)
Add the value from end_cursor to the url: https://www.instagram.com/explore/tags/space/?__a=1&max_id=J0HWE9rjAAAAF0HWE9qvgAAAFiYA
Repeat 3-6 to get newest posts with specific hashtag.
Update to the ?__a=1 url param. This appears to have stopped working with users '/account/?__a=1' endpoints.:( Still works on tags apparently.
Instagram shut down their public API. Here's a quick and dirty workaround in PHP:
<?php
function getPublicInfo($username) {
$url = sprintf("https://www.instagram.com/$username");
$content = file_get_contents($url);
$content = explode("window._sharedData = ", $content)[1];
$content = explode(";</script>", $content)[0];
$data = json_decode($content, true);
return $data['entry_data']['ProfilePage'][0];
}
Not sure for how long it's gonna work. Here's one for Javascript.

Can't get views by insightTrafficSourceType — YouTube Analytics API

So I'm using the 'google-api-client' gem with Rails, and I'm attempting to call the URL below in order to get video views by day and insightTrafficSourceType. This is a call that appears to be allowable from the Available Reports documentation page.
Additionally, I found that I was able to make this call by using the API Explorer tool provided by Google.
URL:
https://www.googleapis.com/youtube/analytics/v1beta1/reports?metrics=views&ids=channel==CHANNEL_ID&dimensions=day,insightTrafficSourceType&filter=video==VIDEO_ID&start-date=2013-01-15&end-date=2013-01-16&start-time=1970-01-01
Result:
{
:error=>
{
"errors"=>[
{
"domain"=>"global",
"reason"=>"invalid",
"message"=>"Unknown identifier (insightTrafficSourceType) given in field parameters.dimensions."
}
],
"code"=>400,
"message"=>"Unknown identifier (insightTrafficSourceType) given in field parameters.dimensions."
}
}
I'm not sure what extra data I can provide in the initial description of this bug, but as stated before I am making the call to the API with the Google::APIClient Ruby library. The actual code itself looks like this:
client.execute(
:api_method => api.reports.query,
:parameters => options
)
You are still referencing the old beta API, i.e., in your URL, you have 'v1beta' and you should have 'v1' there. Try replacing that and running it again. Also, you can look at the api explorer to see the exact URL that should be generated in live examples with your acct (once you enable OAuth) here:
https://developers.google.com/youtube/analytics/v1/
(Look at the bottom of the page.)
Finally, start-time isn't a parameter listed on the production version of the API, so you will want to remove that as well.

How to Add Tag via Asana API

I am trying to do a simple Salesforce-Asana integration. I have many functions working, but I am having trouble with adding a tag to a workspace. Since I can't find documentation on the addTag method, I'm sort of guessing at what is required.
If I post the following JSON to https://app.asana.com/api/1.0/workspaces/WORKSPACEID/tasks:
{"data":{"name":"MyTagName","notes":"Test Notes"}}
The tag gets created in Asana, but with blank notes and name fields. If I try to get a bit more fancy and post:
{"data":{"name":"MyTagName","notes":"Test Notes","followers":[{"id":"MY_USER_ID"}]}}
I receive:
{"errors":[{"message":"Invalid field: {\"data\":{\"name\":\"MyTagName\",\"notes\":\"Test Notes\",\"followers\":[{\"id\":\"MY_USER_ID\"}]}}"}]}
I'm thinking the backslashes may mean that my request is being modified by the post, though debug output shows a properly formatted json string before the post.
Sample Code:
JSONGenerator jsongen = JSON.createGenerator(false);
jsongen.writeStartObject();
jsongen.writeFieldName('data');
jsongen.writeStartObject();
jsongen.writeStringField('name', 'MyTagName');
jsongen.writeStringField('notes', 'Test Notes');
jsongen.writeFieldName('followers');
jsongen.writeStartArray();
jsongen.writeStartObject();
jsongen.writeStringField('id', 'MY_USER_ID');
jsongen.writeEndObject();
jsongen.writeEndArray();
jsongen.writeEndObject();
jsongen.writeEndObject();
String requestbody = jsongen.getAsString();
HttpRequest req = new HttpRequest();
req.setEndpoint('https://app.asana.com/api/1.0/workspaces/WORKSPACEID/tags');
req.setMethod('POST');
//===Auth header created here - working fine===
req.setBody(requestbody);
Http http = new Http();
HTTPResponse res = http.send(req);
return res.getBody();
Any help appreciated. I am inexperienced using JSON as well as the Asana API.
The problem was that I was posting to the wrong endpoint. Instead of workspaces/workspaceid/tags, I should have been using /tags and including workspaceid in the body of the request.
Aha, so you can add tags and even set followers despite the API not mentioning that you can or claiming that followers are read-only.
So to sum up for anyone else interested: POSTing to the endpoint https://app.asana.com/api/1.0/tags you can create a tag like this:
{ "data" : { "workspace": 1234567, "name" : "newtagname", "followers": [45678, 6789] } }
where 1234567 is your workspace ID and 45678 and 6789 are your new followers.
Since you posted this question, Asana's API and developer has introduced Tags. You documentation lays out the answer to your question pretty clearly:
https://asana.com/developers/api-reference/tags
I'm a bit confused by your question. Your ask "how to add a tag" but the first half of your question talks about adding a task. The problem with what you describe there is that you are trying to set a task's followers but the followers field is currently read-only according to Asana's API documentation. That is why you are getting an error. You can not set followers with the API right now.
The second part of your question - with the sample code - does look like you are trying to add a tag. However, right now the Asana API does not support this (at least according to the API documentation). You can update an existing tag but you can't add one.
So, to sum up: at this time the API does not allow you to add followers to a task or to create new tags.

Problems with sharing via LinkedIn a link with equal sign

I've encountered an issue with LinkedIn share API.
I am working on a iPhone project, testing my application on iOS 4.0, 5.0.
I used this project as an example:
[https://github.com/synedra/LinkedIn-OAuth-Sample-Client][1]
I thought I am a genius after successfully implementing this API not only for sharing an update, but also with following format(like shown in [https://developer.linkedin.com/documents/share-api][1]):
<?xml version="1.0" encoding="UTF-8"?>
<share>
<comment>83% of employers will use social media to hire: 78% LinkedIn, 55% Facebook, 45% Twitter [SF Biz Times] http://bit.ly/cCpeOD</comment>
<content>
<title>Survey: Social networks top hiring tool - San Francisco Business Times</title>
<submitted-url>http://sanfrancisco.bizjournals.com/sanfrancisco/stories/2010/06/28/daily34.html</submitted-url>
<submitted-image-url>http://images.bizjournals.com/travel/cityscapes/thumbs/sm_sanfrancisco.jpg</submitted-image-url>
</content>
<visibility>
<code>anyone</code>
</visibility>
</share>
Following advices and examples, I was preparing a JSON string that i was using.
So, i got this:
{
"visibility":
{
"code":"anyone"
},
"comment":"Asd",
"content":
{
"submitted-url":"http://google.com",
"title":"googloo",
"submitted-image-url":"http://pikci.ru/images/img_srchttpwwwcomputerrivercomimagessamsung-chat-335-qwer.jpg"
}
}
Well, with this data inside, it works like a charm. the update is with image, clickable title and stuff. Perfect.
Then, i tried to put a link(because i really needed in purpose of my project) with a Equal sign in it: "=", like for example we have
http://www.google.md/#q=Nicolas+Steno&ct=steno12-hp&oi=ddle&bav=on.2,or.r_gc.r_pw.,cf.osb&fp=8c5a975d815425a&biw=1920&bih=881
Well, if we use this link in submitted-url, and send it, the LinkedIn will receive it, and even will give us a response. But it WONT update to the new status! It's a huge bug for my application, because the share won't work, but more than a half of the shared links will have equal sign in it. It is the third day when i'm fighting with it. I was trying different coding functions, different "smarty-pants" moves, but failed.
If anyone has a clue about what is going on here, I will hugely appreciate it...
When I post this body to LinkedIn I get my status updated:
{
"comment": "Posting from the API using JSON",
"content": {
"submitted-url":
"http://www.google.md/#q=Nicolas+Steno&ct=steno12-hp&oi=ddle&bav=on.2,or.r_gc.r_pw.,cf.osb&fp=8c5a975d815425a&biw=1920&bih=881"
}, "visibility": {
"code": "anyone"
}
}
However, the link itself doesn't resolve correctly. It's likely that something about that URL is tripping up our link shortener - we're working on fixing these issues but in the meantime you could use something like the Google URL shortener URL:
body = {"longUrl": article['articleContent']['resolvedUrl']}
resp,content = http.request("https://www.googleapis.com/urlshortener/v1/url?key=xxx","POST",body=simplejson.dumps(body),headers={"Content-Type":"application/json"})
googleresponse = simplejson.loads(content)
... and then share that to LinkedIn. I realize it's a suboptimal solution, but until the share function gets fixed to handle these URLs it should get you going.

Resources