I'm using tornado web server and to integrate linkedin in my application I'm using the LinkedinMixin class that I add to the framework from an unofficial code in github. All is working perfectly, but I would like to be able to use the share api
POST
http://api.linkedin.com/v1/people/~/shares
The linkedin API is in XML, this is the reason why it's sometimes difficult to integrate it in tornado
https://developer.linkedin.com/documents/api-requests-json
I found this article which tell me to send
{
"contentType":"linkedin-html",
"body":"My Fancy Update"
}
to post an update but it sends me a HTTP 401: Unauthorized fetching http://api.linkedin.com/v1/people/~/shares?...
I would like to know if someone knows another version of linkedinMixin that this one :
https://github.com/facebook/tornado/pull/236/files
And if someone could give me a complete example of share API using JSON
Thanks,
I should probably point out that I have no experience with the LinkedIn API or the Tornado webserver. I have done a lot of work with OAuth, JSON and XML though.
Judging by the class you mentioned, the
def linkedin_request(self, path, callback, access_token=None, post_args=None, **args):
does exactly what you want. No need to bother about requesting JSON, etc. It does it for you.
I haven't really analyzed the classes, but I'd assume that your callback would look something like :
import json
def callback(data):
# If data is a JSON string, parse it. (remove this if data is a dict)
data = json.loads(data)
# Do something with the data
print data
def makeRequest():
something.linkedin_request("/v1/people/~/shares", callback)
I hope that this pointed you in the right direction :-)
Related
I'm working on a project, and I'm completely stuck.
I get the user's location using CLLocation and am able to get the place name using CLGeocoder, and using this I've constructed a URL to search the Google Places Web API.
My question is, how can I actually complete the search and return the top place result's phone number? Any help would be much appreciated!
let url: URL = URL(fileURLWithPath: "https://maps.googleapis.com/maps/api/place/textsearch/json?query=taxi+" + placeMark.locality!+"&key=" + self.GAPIKEY)
This is the URL I've come up in case that helps
The first thing you need to do is an HTTP GET on the URL to get the API results. Consult the following SO question for various ways to do that:
How to make an HTTP request in Swift?
The data returned will be a JSON document in the format described in the Google Places API Docs. Look for the formatted_phone_number and/or international_phone_number fields. See Working with JSON in Swift for how to parse the JSON string.
I can't seem to find the section in their api reference. I tried it as a searchquery but it doesn't seem to work. api.soundcloud.com/stream or /explore return a 404, so that doesn't work either
Thats actually not a part of the public API.
But its quite easy to grab your call from the dev console.
Thats an example call from my user:
https://api-v2.soundcloud.com/stream?user_id=e87647259112403eaa239b6e2c510e46&sc_a_id=e87647259112403eaa239b6e2c510e46&user_urn=soundcloud%3Ausers%3A1672444&promoted_playlist=true&limit=10&offset=0&linked_partitioning=1&client_id=02gUJC0hH2ct1EGOcYXQIzRFU91c72Ea&app_version=a089efd
To make that call work, you need to modify the headers.
These answers may help you:
Retrieving the "recommended" playlist via API call?
soundcloud: Is api-v2 allowed to be used and is there documentation on it?
How to get "all" tracks related to an artist with Souncloud API
Using these endpoints does not go inline with SoundClouds TOS.
I'm using the Facebook Graph API, Mobile hosting API to post a link with the following:
https://graph.facebook.com/{APPID}/app_link_hosts?access_token={ACCESS_TOKEN}&name=Puzzle_1420352145684&ios=[{"url":"MyAPP://playerPuzzles/1420352145684","app_store_id":{MYAPPID},"app_name":"MyAPP"}]&web={"should_fallback":false}
I get the correct result in the form of the ID of the link, with no error.
But when I query the link with
https://graph.facebook.com?ids={LINK}&access_token={ACCESS_TOKEN};
I don't get any app-link data the object is there but empty not even the name.
{"http://fb.me/777314042342441" = {
id = "http://fb.me/777314042342441";
};
}
Is there something wrong in my posting that doesn't allow the data to get posted?
Thanks for you help in advance.
It seems that the facebook documenatation is wrong. I finally found a solution using the graph explorer.
To correctly fetch the data use this style of URL.
https://graph.facebook.com/{APP-LINK-ID}?fields=ios,name,web&access_token={ACCESS_TOKEN};
Please note that you have to call out all the fields you want. The object at least for me didn't include the app_links structure like the documentation.
Here is the link to the wrong Index API
Here is the app_links object structure you can see all the fields you can fetch.
Hope this helps everyone.
I am having some problems working around with Scribe java library for Twitter.
I succeeded in logging in twitter using the library and collecting the user profile data, but can't seem to figure out how to post tweets on behalf of the user.
I looked at the example from the github page but it was only for accessing data, not posting.
This is a method I came up with, after doing some research,
what should I pass on the URL, if I was reading data then url="https://api.twitter.com/1.1/account/verify_credentials.json" would have been valid. But since I am trying to post a tweet. What should I do??
def request(verb: Verb, url: String, accessToken: org.scribe.model.Token, reqBody: String, d: String): String = {
val request: OAuthRequest = new OAuthRequest(verb, url)
request.addBodyParameter("status", reqBody)
service(d).signRequest(accessToken, request)
val response: Response = request.send
response.getBody
}
The service method, for connection
def service(url: String): OAuthService = new ServiceBuilder()
.provider(classOf[TwitterApi.Authenticate])
.apiKey("XXXXX")
.apiSecret("XXXXX")
.callback(url)
.build
Can someone, provide me with some ideas and pointers.
Thank you,
#update: It seems, for posting status , url=https://api.twitter.com/1.1/statuses/update.json?status=helllllooooo is the required URL,thanks to this SO post , seems to do the trick,
So,If for additional features:
How to post hashtags, Is appending #hash1 in the message body
enough, or there are special way to do so??
And how do we post links, like any normal links, appends the links in
message??
And how can we share links, with images??
I have been researching for the answers myself as well, hope you could provide me with some insights as well,
I think the pieces of documentation you need are the POST statuses/update page:
https://dev.twitter.com/docs/api/1.1/post/statuses/update
and this specific FAQ about link wrappers...
https://dev.twitter.com/docs/tco-link-wrapper/faq#When_are_links_wrapped_with_t.co_Do_I_need_to_make_an_extra_API_call
In summary, hashtags and URLs/shortening with look after themselves - you just need to make sure you URL encode as appropriate.
You share a link with an image the same way you share any other URL (you just include it in the URL-encoded string that's POSTed). An image will show up if the underlying site is setup/the target URL is tagged to present a Twitter cards, as described here:
https://dev.twitter.com/docs/cards
Is there a way to get all status types from the JIRA webservice, either through the api or through a JQL request? (The issue status is the field that is mapped to the swimlanes when the board is set up)
Whith JIRA REST API you can :
rest/api/2/status
or for each project :
rest/api/2/project/{projectIdOrKey}/statuses
see the online rest api browser : it's a wonderful tool :
https://jira.atlassian.com/plugins/servlet/restbrowser#/resource/api-2-status
For future reference, to see what's in a project's swimlanes for a JIRA agile board you make a request like this: https://jira.atlassian.com/rest/greenhopper/1.0/xboard/work/allData.json?rapidViewId=560 and it will return the relevant information.
Each board has a rapidViewId so you'll have to query for that yourself using a request like this: /rest/greenhopper/1.0/rapidview.
All this stuff can be found here: https://jira.atlassian.com/plugins/servlet/restbrowser#/resource/greenhopper-1-0-rapidview
This is for future reference so that people don't have to go through the same trouble I did when trying to figure this out. Hope it helps!