EDIT - Here is the 1st object/record in the response. I get a total of 20 records, including this:
Note: The response has been parsed to remove unicode i.e. u' and has ' replaced by " to make this into a valid json.
{
"jobs": {
"_total": 1811,
"_count": 20,
"_start": 0,
"values": [{
"siteJobUrl": "xxx",
"company": {
"id": 21836,
"name": "CyberCoders"
},
"postingDate": {
"year": 2013,
"day": 10,
"month": 6
},
"descriptionSnippet": "Software Engineer- Hadoop, HDFS, HBaseWe are a well known consumer product development company and we are looking to add a Hadoop Engineer to our Engineering team. You will be working with the latest and greatest technologies to design, develop, and implement connectivity products that allow efficient exchange of data between our core database engine and the Hadoop ecosystem.What you need for thi",
"expirationDate": {
"year": 2013,
"day": 10,
"month": 7
},
"position": {
"industries": {
"_total": 1,
"values": [{
"code": "4",
"id": 4,
"name": "Computer Software"
}]
},
"title": "Software Engineer- Hadoop, HDFS, HBase",
"experienceLevel": {
"code": "2",
"name": "Entry level"
},
"location": {
"country": {
"code": "us"
},
"name": "Greater Pittsburgh Area"
},
"jobFunctions": {
"_total": 1,
"values": [{
"code": "it",
"name": "Information Technology"
}]
},
"jobType": {
"code": "F",
"name": "Full-time"
}
},
"customerJobCode": "CCW-ssehadooppaccw",
"locationDescription": "Pittsburgh, PA",
"jobPoster": {
"headline": "Senior Executive Technical Recruiter at CyberCoders (949)885-5121 chelsea.whalen#cybercoders.com",
"lastName": "W.",
"id": "y2zfe5j76F",
"firstName": "Chelsea"
},
"id": 6007298
},
I am trying to use the below python library to make a job search api call to the linkedin REST API.
https://github.com/ozgur/python-linkedin/
I can access 1st page output just fine. But when I increment the start to point to next page, I still get the same response. What am I missing here?
Here is my code snippet:
authentication = LinkedInAuthentication(API_KEY, API_SECRET, RETURN_URL,
PERMISSIONS.enums.values())
.......
application = LinkedInApplication(authentication)
........
# This is my request
response = application.search_job(
selectors=[{'jobs':
['id',
'customer-job-code',
'posting-date','expiration-date',
{'company':['id','name']},
{'position':['title',
'location',
'job-functions.',
'industries',
'job-type',
'experience-level']},
'skills-and-experience',
'description-snippet',
'salary',
{'job-poster':['id',
'first-name',
'last-name',
'headline']},
'referral-bonus',
'site-job-url',
'location-description']}],
params={'keywords': 'hadoop','count': 20},
headers={'start':20})
I had posted the query on linkedin developer forum too - http://developer.linkedin.com/forum/new-python-client-oauth-20
But got no response. I am new to python which is making it further difficult for me.
Appreciate your help.
Related
My main goal is to get all today meetings in a sharepoint site (using python)
What i already do:
Filter meetings properly and get the specific fields
?$filter=fields/fRecurrence eq 1 and fields/EndDate ge '2022-11-08 18:00:00'&$expand=fields($select=Title,EventDate,EndDate,fRecurrence,RecurrenceData,EventType, Duration,TimeZone)
Request all meetings with all needed info, inclusive RecurrenceData (XLM)
There is the HTTP request and a response sample (some items and info as been removed):
REQUEST:
https://graph.microsoft.com/v1.0/sites/[SITE]/sites/[SITE]/lists/[ID]/items?$filter=fields/fRecurrence eq 1 and fields/EndDate ge '2022-11-08 18:00:00'&$expand=fields($select=Title,EventDate,EndDate,fRecurrence,RecurrenceData,Eventype, Duration,TimeZone)
RESPONSE:
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites('[SITE]')/sites('[SITE]')/lists('[ID]')/items(fields(Title,EventDate,EndDate,fRecurrence,RecurrenceData,EventType,Duration,TimeZone,RecurrenceID,UniqueId))",
"value": [
{
"#odata.etag": "[TAG]",
"createdDateTime": "2019-09-09T17:42:40Z",
"eTag": "[TAG]",
"id": "2065",
"lastModifiedDateTime": "2019-09-10T08:51:34Z",
"webUrl": "https://[BUISNESS COMPANY].sharepoint.com/teams/[THINGS]/[THINGS]/Lists/[ROOM NAME]/2022_.000",
"createdBy": {
"user": {
"email": "[USER]",
"id": "[UID]",
"displayName": "[USER NAME]"
}
},
"lastModifiedBy": {
"user": {
"email": "[USER]",
"id": "[UID]",
"displayName": "[USER NAME]"
}
},
"parentReference": {
"id": "[ID]",
"siteId": "[BUISNESS COMPANY].sharepoint.com,[UID],[UID]"
},
"contentType": {
"id": "[THINGS]",
"name": "Event"
},
"https://graph.microsoft.com/v1.0/$metadata#sites('[SITE]')/sites('[SITE]')/lists('[ID]')/items(fields(Title,EventDate,EndDate,fRecurrence,RecurrenceData,EventType,Duration,TimeZone,RecurrenceID,UniqueId))/$entity",
"fields": {
"#odata.etag": "[TAG]",
"Title": "TITLE",
"EventDate": "2019-12-10T10:00:00Z",
"EndDate": "2169-09-12T10:00:00Z",
"fRecurrence": true,
"EventType": 1,
"Duration": 3600,
"RecurrenceData": "<recurrence><rule><firstDayOfWeek>mo</firstDayOfWeek><repeat><monthlyByDay tu=\"TRUE\" weekdayOfMonth=\"second\" monthFrequency=\"3\" /></repeat><repeatForever>FALSE</repeatForever></rule></recurrence>",
"TimeZone": [THINGS],
"UniqueId": "[UID]"
}
}, {...}, {...}, ... ]
In "EventDate": "2019-12-10T10:00:00Z" and the "EndDate": "2169-09-12T10:00:00Z" we have the start and end date of the "event", however this event is recurent, and have some "rules" -> RecurrenceData.
QUESTIONS:
HOW CAN I PARSE THE RULES (using python) TO KNOW IF WE HAVE THIS MEETING TODAY (2022-11-08 18:00:00) OR NOT;
2)OR, HOW CAN I MEKE A REQUEST TO THE SERVER AND RECEVE ONLY THE TODAYS MEETINGS (DOESN'T METTER IF RECURENT OR NOT)
Maybe usefull links:
In C#
Sherepoint recurrence data schema
{
"meta": {
"code": 200
},
"response": {
"holidays": [
{
"name": "New Year's Day",
"description": "New Year\u2019s Day is celebrated many countries such as in India on the January 1 in the Gregorian calendar.",
"country": {
"id": "in",
"name": "India"
},
"date": {
"iso": "2021-01-01",
"datetime": {
"year": 2021,
"month": 1,
"day": 1
}
},
"type": [
"Optional holiday"
],
"locations": "All",
"states": "All"
},
{
"name": "Lohri",
"description": "Lohri is a restricted holiday in India",
"country": {
"id": "in",
"name": "India"
},
"date": {
"iso": "2021-01-13",
"datetime": {
"year": 2021,
"month": 1,
"day": 13
}
},
"type": [
"National holiday"
],
"locations": "All",
"states": "All"
}
]
}
}
This is my json file saved as dates.json.
I want to search for New Year's day value in the key name and then get the value of the iso key.
How can i do that?
I am a beginner in python and json. so please tell me how to do this
Is there any search algorith or a library that can help me?
One way to do it is using the modules json and jsonpath-rw-ext.
Use json module to read the json file and jsonpath-rw-ext to parse/filter.
https://github.com/sileht/python-jsonpath-rw-ext
I made it work for your example. Take a look at this.
#!/usr/bin/env python3
import json
import jsonpath_rw_ext
with open('dates.json') as json_file:
data = json.load(json_file)
result = jsonpath_rw_ext.parse("$..holidays[?(#.name=='New Year\\'s Day')]").find(data)
print([x.value for x in result])
To get the iso value use the code below.
#!/usr/bin/env python3
import json
import jsonpath_rw_ext
with open('dates.json') as json_file:
data = json.load(json_file)
result = jsonpath_rw_ext.parse("$..holidays[?(#.name=='New Year\\'s Day')].date.iso").find(data)
print(result[0].value)
In my python project I have to implement paypal recurring payments.
I have installed the paypal sdk and created a file to create a PayPal payment page, like this:
import paypalrestsdk
from paypalrestsdk import BillingPlan
from paypalrestsdk import BillingAgreement
from paypalrestsdk import Payment
import webbrowser
from urllib import parse
paypalrestsdk.configure({
'mode': 'sandbox', # sandbox or live
'client_id': <my app client id>,
'client_secret': <my app secret>})
def create_bill():
billing_plan = BillingPlan({
"name": "Plan with Regular and Trial Payment Definitions",
"description": "Plan with regular and trial payment definitions.",
"type": "INFINITE",
"payment_definitions": [
{
"name": "Regular payment definition",
"type": "REGULAR",
"frequency": "MONTH",
"frequency_interval": "1",
"amount": {
"value": "100",
"currency": "USD"
},
"cycles": "0",
"charge_models": [
{
"type": "SHIPPING",
"amount": {
"value": "10",
"currency": "USD"
}
},
{
"type": "TAX",
"amount": {
"value": "12",
"currency": "USD"
}
}
]
},
{
"name": "Trial payment definition",
"type": "TRIAL",
"frequency": "WEEK",
"frequency_interval": "5",
"amount": {
"value": "9.19",
"currency": "USD"
},
"cycles": "2",
"charge_models": [
{
"type": "SHIPPING",
"amount": {
"value": "1",
"currency": "USD"
}
},
{
"type": "TAX",
"amount": {
"value": "2",
"currency": "USD"
}
}
]
}
],
"merchant_preferences": {
"setup_fee": {
"value": "1",
"currency": "USD"
},
"return_url": "https://example.com",
"cancel_url": "https://example.com/cancel",
"auto_bill_amount": "YES",
"initial_fail_amount_action": "CONTINUE",
"max_fail_attempts": "0"
}
})
# Create billing plan
if billing_plan.create():
print("Billing Plan [%s] created successfully" % billing_plan.id)
# Activate billing plan
if billing_plan.activate():
billing_plan = BillingPlan.find(billing_plan.id)
print("Billing Plan [%s] state changed to %s" % (billing_plan.id, billing_plan.state))
return billing_plan
else:
print(billing_plan.error)
else:
print(billing_plan.error)
def create_agreement(ret_bil):
billing_agreement = BillingAgreement({
"name": "Fast Speed Agreement",
"description": "Agreement for Fast Speed Plan",
"start_date": "2018-03-29T00:37:04Z",
"plan": {
"id": str(ret_bil.id)
},
"payer": {
"payment_method": "paypal"
},
"shipping_address": {
"line1": "StayBr111idge Suites",
"line2": "Cro12ok Street",
"city": "San Jose",
"state": "CA",
"postal_code": "95112",
"country_code": "US"
}
})
if billing_agreement.create():
# Extract redirect url
for link in billing_agreement.links:
if link.method == "REDIRECT":
# Capture redirect url
redirect_url = str(link.href)
# REDIRECT USER TO redirect_url
webbrowser.open(redirect_url)
else:
print(billing_agreement.error)
if __name__ == "__main__":
create_agreement(create_bill())
But when I run the code above, Paypal starts with agreement description but I can't see the item details and description defined in the BilingPlan (I expected to see the detail about items, trial period, amount, recurrence etc)
Is there something wrong in my code? This is the first time I implement Paypal in my project; have I written my code correctly to implement recurrent payments?
So many Thanks in advance
PayPal will not show the recurring period, amount and service details.
You have to show that in your website's page and proceed to PayPal.
I have this json file which includes information about pages I have retrieving using this
python code:
import facebook # pip install facebook-sdk
import json
import codecs
# Create a connection to the Graph API with your access token
ACCESS_TOKEN = ''#my access token
g = facebook.GraphAPI(ACCESS_TOKEN)
s=g.request('search', { 'q' : '&','type' : 'page', 'limit' : 5000 , 'locale' : 'ar_AR' })
f = open("sampels.txt", 'w')
f.write(json.dumps(s, indent=1))
f.close()
#########################################################
this is my samples json file a snapshot of it:
{
"paging": {
"next": "https://graph.facebook.com/search?limit=5000&type=page&q=%26&locale=ar_AR&access_token=CAACEdEose0cBAIRlSOXkyk1lIMUIWViAoz5lf5t0pSdsu6lg5ZANJuYMIPZCy5N9KFQoLnpi1oxD8tNIaabWackCO31UYaAGkb38IPHxI33ldbRQDXJ02CtJrwE8NI4mZAz20OznLfuCpypDbxNYF3p9XauZCtoywoS9KJwAgW8NYgZCpD4ZBKfCBR5jjXnbcZD&offset=5000&__after_id=92240239536"
},
"data": [
{
"category": "\u0627\u0644\u062a\u0639\u0644\u064a\u0645",
"name": "The London School of Economics and Political Science - LSE",
"category_list": [
{
"id": "108051929285833",
"name": "\u0627\u0644\u0643\u0644\u064a\u0629 \u0648\u0627\u0644\u062c\u0627\u0645\u0639\u0629"
},
{
"id": "187751327923426",
"name": "\u0645\u0646\u0638\u0645\u0629 \u062a\u0639\u0644\u064a\u0645\u064a\u0629"
}
],
"id": "6127898346"
},
{
"category": "\u0628\u0636\u0627\u0626\u0639 \u0627\u0644\u0628\u064a\u0639 \u0628\u0627\u0644\u062a\u062c\u0632\u0626\u0629 \u0648\u0628\u0636\u0627\u0626\u0639 \u0627\u0644\u0645\u0633\u062a\u0647\u0644\u0643\u064a\u0646",
"name": "Stop & Shop",
"category_list": [
{
"id": "169207329791658",
"name": "\u0645\u062d\u0644 \u0628\u0642\u0627\u0644\u0629"
}
],
"id": "170000993071234"
},
{
"category": "\u0628\u0636\u0627\u0626\u0639 \u0627\u0644\u0628\u064a\u0639 \u0628\u0627\u0644\u062a\u062c\u0632\u0626\u0629 \u0648\u0628\u0636\u0627\u0626\u0639 \u0627\u0644\u0645\u0633\u062a\u0647\u0644\u0643\u064a\u0646",
"name": "C&A",
"category_list": [
{
"id": "186230924744328",
"name": "\u0645\u062a\u062c\u0631 \u0645\u0644\u0627\u0628\u0633"
}
],
"id": "109345009145382"
},
{
"category": "\u0645\u0646\u0638\u0645\u0629 \u063a\u064a\u0631 \u0631\u0628\u062d\u064a\u0629",
"name": "Rock and Roll Hall of Fame + Museum",
"category_list": [
{
"id": "396255327112122",
"name": "\u0645\u062a\u062c\u0631 \u0645\u0648\u0633\u064a\u0642\u0649"
},
now what I want to do is to get the next field in order to get my next 5000 page into my database.
I have tried a lot but I couldn't figure out away to do this can any body tell me how to take the next URL and how pass it to the request function I have in my code.?
g.request() returns a Python dict which gives you access to the paging/next url. Why do you dump it as json and write it to file instead of just using it ?
I am using Django to receive and process push notifications from the foursquare real-time api. Each checkin is pushed as a POST request to my server containing a single parameter named checkin. I am trying to grab the value of the checkin parameter and convert it to a python dict. However, calling json.loads always results in the following error:
NameError: name 'true' is not defined
I know the json is valid, so I must be doing something wrong.
The code is:
import json
def push(request):
if request.is_secure():
checkin_json = request.POST['checkin']
checkin = json.load(request.POST)
The body of the post request is:
"checkin =
{
"id": "4e6fe1404b90c00032eeac34",
"createdAt": 1315955008,
"type": "checkin",
"timeZone": "America/New_York",
"user": {
"id": "1",
"firstName": "Jimmy",
"lastName": "Foursquare",
"photo": "https://foursquare.com/img/blank_boy.png",
"gender": "male",
"homeCity": "New York, NY",
"relationship": "self"
},
"venue": {
"id": "4ab7e57cf964a5205f7b20e3",
"name": "foursquare HQ",
"contact": {
"twitter": "foursquare"
},
"location": {
"address": "East Village",
"lat": 40.72809214560253,
"lng": -73.99112284183502,
"city": "New York",
"state": "NY",
"postalCode": "10003",
"country": "USA"
},
"categories": [
{
"id": "4bf58dd8d48988d125941735",
"name": "Tech Startup",
"pluralName": "Tech Startups",
"shortName": "Tech Startup",
"icon": "https://foursquare.com/img/categories/building/default.png",
"parents": [
"Professional & Other Places",
"Offices"
],
"primary": true
}
],
"verified": true,
"stats": {
"checkinsCount": 7313,
"usersCount": 565,
"tipCount": 128
},
"url": "http://foursquare.com"
}
}"
Try json.loads(checkin_json) instead of json.load(request.POST). Notice the extra 's'.
change checkin = json.load(request.POST) to checkin = json.loads(checkin_json)
On python, boolean values are Capitalized (first letter is uppercase): True/False.
Check this.
EDIT:
Pay attentiot at this lines:
"primary": true
}
],
"verified": true,
Both "true" values are lowercase and need to be capitalized