php


Does the Marketo REST API asset Token work?


I am following this part of the documentation: http://developers.marketo.com/rest-api/assets/tokens/ and I always get the following an error: Fields cannot be empty.
Have anyone make it worked?
public function create_token($folder_id,$name,$content,$folder_type = 'Program')
{
$folder_id = intval($folder_id);
$endpoint = 'rest/asset/v1/folder/'.$folder_id.'/tokens';
$body = new stdClass();
$body->folderType = $folder_type;
$body->name = $name;
$body->type = 'rich text';
$body->value = $content;
$body_encoded = json_encode($body);
echo $url = $this->url . $endpoint . ".json?access_token=" . self::$token;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body_encoded);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response);
}
The reason for the Content-Type header was a suggestion from Marketo: https://www.screencast.com/t/CL5ZtPo1o
This is the answer from the request I keep getting:
object(stdClass)#1934 (4) {
["success"]=>
bool(false)
["warnings"]=>
array(0) {
}
["errors"]=>
array(4) {
[0]=>
object(stdClass)#1935 (2) {
["message"]=>
string(20) "name cannot be null."
["code"]=>
string(3) "701"
}
[1]=>
object(stdClass)#1936 (2) {
["message"]=>
string(20) "type cannot be null."
["code"]=>
string(3) "701"
}
[2]=>
object(stdClass)#1937 (2) {
["message"]=>
string(101) "Token type is either null, blank or invalid. Please refer to the documentation for valid token types."
["code"]=>
string(3) "701"
}
[3]=>
object(stdClass)#1938 (2) {
["message"]=>
string(21) "value cannot be null."
["code"]=>
string(3) "701"
}
}
["requestId"]=>
string(16) "11d1#15b49284636"
}

Related Links

SQL request syntax
CodeIgniter HMVC How Define a SubModule User(User Logged)
Steam web api: How to get the tags for items in Steam Inventory
how to retrieve value from database using codeigniter
php pdo fetch generates wrong items from wrong table
LOAD DATA LOCAL INFILE - php 5.5 not working
What i need for doing this regex or split?
Yeoman - php project
Adding new keys & values to Associative array in PHP?
Doctrine Mongodb Id is blank
.txt date on HTML website, explode()
Returned Parameters in PHP PDO MSSQL
Store column result in variable
Show HTML if URL contains a defined domain name, else show something else
How configure apache to allow simultaneous requests from the same ip
Use variable as namespace

Categories

HOME
nam
automapper
facebook-messenger
scroll
systemd
antd
tcsh
dry
openlayers-3
ontology
repair
haxe
timber
log4j2
fullcalendar-scheduler
trace32
sonicwall
google-sites
pe
spring-ldap
pst
ratio
openbravo
plantuml
xmlunit
custom-keyboard
cups
des
wdk
cartopy
llvm-ir
text-decorations
widestring
httphandler
kitura
absolute
directwrite
ssi
gnome-terminal
test-data
http-basic-authentication
wikimapia
hmmlearn
prefetch
fitbit
yargs
p6spy
traversable
piping
processor
jeasyui
android-expansion-files
variable-length-array
html.actionlink
calcite
gluon-desktop
uitest
modern.ie
darwin
relational-model
clarion
sablecc
juttle
rebar
window-resize
bittorrent-sync
pageviews
lsa
progress-db
ember-table
ax
xs
arel
background-thread
examine
django-filebrowser
ckeditor.net
lynx
multiscaleimage
daap
idispatch
stretch
arrow
jdom
firebird1.5
will-paginate
botnet
airprint
anonymous-types
regression-testing
formal-semantics
android-2.1-eclair
activestate
pinax
rtti
autobench
efs

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile