marketo / rest-sample-code Goto Github PK
View Code? Open in Web Editor NEWMarketo REST API sample code.
Home Page: http://developers.marketo.com/rest-api/
License: MIT License
Marketo REST API sample code.
Home Page: http://developers.marketo.com/rest-api/
License: MIT License
The program to MergeLeads has a function called csvString. In that function, there is an incrementer $i. However, $i is never incremented, on line 52, please add $i++; So that the ideas are properly joined by commas
Hey!
I can't find a code examples of the Forms & Form Fields requests in the PHP folder.
Could you please add?
Hi
I am using Rest api to export lead activities using "activities" API. I am able to fetch the activity data, but when I match day wise data count from exported data against the data count from marketo, I am having count difference. Minor difference is understandable. Please suggest.
Testing PHP Code:
$url = $this->host . "/rest/v1/activities.json?access_token=" "&activityTypeIds=9,10,11&nextPageToken=" . $this->nextPageToken;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',));
$response = curl_exec($ch);
Thanks.
I'm unclear how to upsert to the push.json endpoint.
I've successfully pushed to Marketo, and associated the lead by email, but it fails to continue tracking events like page visits and link clicking once that happened. I assume the cookie value was sent incorrectly.
Every example that I see has the cookie being urlencoded()
'd, and then sent as part of the URL. I'm trying to send it as part of the mktToken
field in the input
array of JSON objects.
Does this look right, or am I screwing this up?
$curl_post_data = json_encode(array(
"lookupField" => "email",
"reason" => "Logged in",
"input" => array(
array(
"email" => $userEmail,
"mktToken" => urlencode(filter_input(INPUT_COOKIE, "_mkto_trk")),
"UserName" => $user['username']
)
),
"programName" => "Lead Acquisition"
)
);
Or should I not urlencode
the cookie value?
Guys, could you please provide a solution?
Can't clone some of our emails.
Request:
POST https://xxx.mktorest.com/rest/asset/v1/email/xxx/clone.json?access_token=xxx
&name=xxx - [it-it]&folder={"id":14,"type":"Folder"}
Response:
{"requestId":"12caa#1636d21b670","success":false,"errors":[{"code":"611","message":"System error"}]}
Your PushLeadToMarketo.php example seems pretty straightforward, much simpler than the convoluted Marketo REST api docs I have seen so far. With that said, since I have no direct experience with Marketo yet, how should I direct a Marketo customer to get me the following details and make sure it has the right permissions for me to simply push leads to their system. This is from within your example:
private $host = "";//CHANGE ME
private $clientId = "";//CHANGE ME
private $clientSecret = "";//CHANGE ME
Also, are there no such things as leads list that they can be added to instead of some programname with a static string that does not appear to be predefined within marketo.
I am attempting to send a request to '/rest/asset/v1/smartLists.json' to get all SmartLists. I am authenticating with Marketo fine and recieving an access token that I include in the headers of each of my subsequent requests . Additionally, the documentation states that if our instance did not have this capability, the response code would be >1000 (It's some number I can't remember off the top of my head). However, I did not get this response code, but rather 403, which is a forbidden request. I am hoping to figure out why I am not getting a valid response, but there is no documentation for troubleshooting this endpoint.
Code:
`
def get_smartlist_ids(config, access_token):
identity_url = config['identity_url']
headers = {
'Authentication': 'Bearer {}'.format(access_token),
}
url = '{}/rest/asset/v1/smartLists.json'.format(identity_url)
response = requests.get(url, headers=headers)
return response
mkto_config = {
'client_id': [redacted],
'client_secret': [redacted],
'identity_url': [redacted]
}
access_token_response = get_mkto_access_token(mkto_config)
access_token = access_token_response.json()['access_token']
print(access_token_response.status_code)
print(access_token_response.json())
smartlist_ids = get_smartlist_ids(mkto_config, access_token)
print(smartlist_ids.status_code)
print(smartlist_ids.headers)
print(smartlist_ids.request.headers)
print(smartlist_ids.text)
print(smartlist_ids.url)
`
And the Output:
`
200
{'access_token': '[redacted]', 'token_type': 'bearer', 'expires_in': 337, 'scope': '[email protected]'}
403
{'Server': 'nginx', 'Date': 'Thu, 29 Sep 2022 17:54:55 GMT', 'Content-Type': 'text/html', 'Content-Length': '162', 'Connection': 'keep-alive'}
{'User-Agent': 'python-requests/2.25.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Authentication': 'Bearer [redacted]'}
<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx</center>
</body>
</html>
[redacted]/rest/asset/v1/smartLists.json
`
Let me know if I can clarify or provide more information in order to help. Thanks in advance for the help!
Are you going to add the ability to use the new API to export?
Currently there are no examples for modern applications using javascript/node.js.
It would be also interesting to see some examples with specific frameworks like React/Next.js.
Trying to move files from one Marketo instance to another. Marketo support said to use the api. The PHP code for retrieving files and folders works, but when I try to create the file from one marketo instance onto the new one using the api, I get a couldn't open file ...
. I am providing the file url that I get in response from the rest api for querying files.
Hi,
I'm using POST: /rest/v1/leads.json with
$lookupField = email
$action = createOrUpdate
data:
[
{
email: [email protected],
firstName: Jacob
},
{
email: [email protected],
firstName: Dani
}
]
and here is an example of my response:
{
"requestId": "1ddd0#1fd5f0ssss64d",
"result": [
{
"id": 514,
"status": "updated"
},
{
"status": "skipped",
"reasons": [
{
"code": "1007",
"message": "Multiple lead match lookup criteria"
}
]
}
],
"success": true
}
is there a way to add the email to the response results using marketo api?
Code generates a 400 error. This seems to be due to a missing CURLOPT_POSTFIELDS. However, if you try to post the access token, losing lead, and the merge in crm values as posted fields, you will get 1003 errors.
This will generate a 1003 Error
public function postData(){ $url = $this->host . "/rest/v1/leads/" . $this->id ."/merge.json"; $fields = array( 'access_token' => urlencode($this->getToken()), 'leadIds' => urlencode($this::csvString($this->leadIds)), 'mergeInCRM' => urlencode('true') ); foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string,'&'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json','Content-Type: application/json')); curl_setopt($ch, CURLOPT_POST, count($fields)); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_getinfo($ch); $response = curl_exec($ch); return $response; }
Sending an empty set of post fields gets rid of the 400 error
public function postData(){ $url = $url = $this->host . "/rest/v1/leads/" . $this->id ."/merge.json?access_token=" . $this->getToken() . "&leadIds=" . $this::csvString($this->leadIds); $fields = array(); foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string,'&'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json','Content-Type: application/json')); curl_setopt($ch, CURLOPT_POST, count($fields)); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_getinfo($ch); $response = curl_exec($ch); return $response; }
Sending without the mergeInCRM parameter, returns a success. With the mergeInCRM set to true I get a 611 error when merging a contact to a lead. The call will convert the lead to a contact and assign it a new marketo ID. If you run the merge again with the existing contact and the new contact, the contacts are merged in Marketo, but not in Salesforce. It seems the API is just as poor at merging as within the marketo platform natively. It's best just to merge leads/contacts within SF.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.