i'm try to write dailymotion api upload php code
i'm use example code from https://developer.dailymotion.com/guides
it's work great
and i want add Geoblocking only allow Japan
this is my code
require_once 'Dailymotion.php';
// Account settings
$apiKey = 'xxxxxxxxxxxxxxxxxx';
$apiSecret = 'xxxxxxxxxxxxxxxxxx';
$testUser = 'xxxxxxxxxxxxxxxxxx#xxxx.com';
$testPassword = 'xxxxxxxxxxxxxxxxxx';
$videoTestFile = 'C:/output.mp4';
// Scopes you need to run your tests
$scopes = array(
'userinfo',
'feed',
'manage_videos',
);
// Dailymotion object instanciation
$api = new Dailymotion();
$api->setGrantType(
Dailymotion::GRANT_TYPE_PASSWORD,
$apiKey,
$apiSecret,
$scopes,
array(
'username' => $testUser,
'password' => $testPassword,
)
);
$url = $api->uploadFile($videoTestFile);
$result = $api->post(
'/videos',
array(
'url' => $url,
'title' => 'Dailymotion PHP SDK upload test 2',
'tags' => 'dailymotion,api,sdk,test',
'channel' => 'videogames',
'published' => true,
'geoblocking' => 'JP', // i'm add this line
)
);
var_dump($result);
but i got this error
Fatal error: Uncaught exception 'DailymotionAuthRequiredException' with message 'Insufficient rights for the `geoblocking' parameter of route `POST /videos'. Required scopes: manage_videos'
anyone can tell me
what i'm doing wrong and help me fix this problem
thank you
'geoblocking' => 'JP'
change to 'geoblocking' => 'jp'
your code will be
require_once 'Dailymotion.php';
// Account settings
$apiKey = 'xxxxxxxxxxxxxxxxxx';
$apiSecret = 'xxxxxxxxxxxxxxxxxx';
$testUser = 'xxxxxxxxxxxxxxxxxx#xxxx.com';
$testPassword = 'xxxxxxxxxxxxxxxxxx';
$videoTestFile = 'C:/output.mp4';
// Scopes you need to run your tests
$scopes = array(
'userinfo',
'feed',
'manage_videos',
);
// Dailymotion object instanciation
$api = new Dailymotion();
$api->setGrantType(
Dailymotion::GRANT_TYPE_PASSWORD,
$apiKey,
$apiSecret,
$scopes,
array(
'username' => $testUser,
'password' => $testPassword,
)
);
$url = $api->uploadFile($videoTestFile);
$result = $api->post(
'/videos',
array(
'url' => $url,
'title' => 'Dailymotion PHP SDK upload test 2',
'tags' => 'dailymotion,api,sdk,test',
'channel' => 'videogames',
'published' => true,
'geoblocking' => 'jp' // NO , in last line
)
);
var_dump($result);
Related
I have configured Zend Framework2 in my local machine (ubuntu 14.04 LTS) with IMB_db2 driver as below.
global.php
$conn_string = "DATABASE='';HOSTNAME='xxx';PORT='xxx';PROTOCOL=TCPIP;UID='xxx';PWD='xxx'";
return array(
'db' => array(
'driver' => 'ibmdb2',
'database' => $conn_string,
'username' => '',
'password' => '',
'hostname' => '',
'port' => '',
'driver_options' => array(
'DB2_ATTR_CASE' => DB2_CASE_LOWER
),
'platform_options' => array(
'quote_identifiers' => false
)
),
'service_manager' => array(
'factories' => array('Zend\Db\Adapter\Adapter' => 'Zend\Db\Adapter\AdapterServiceFactory'),
),
);
local.php
return array('db' => array('username' => 'xxx','password' => 'xxx',));
Using zend adapter I have called the stored procedure placed in a iseries box as below.
$sm = $this->getServiceLocator();
$this->adapter = $sm->get('Zend\Db\Adapter\Adapter');
$stmt = db2_prepare($this->adapter, 'Call <Procedure name>("xxx","xxx","?","?")');
if (!$stmt) {
die('Preparing Statement failed.' . db2_stmt_error());
}
From the above snippet I am getting 'Preparing Statement failed.' with out any error message.
When I print $this->adapter, it is giving connection object.
Can any one help me on this, please?
I am trying to get a request token from Bitbucket but I'm getting "BAD REQUEST - Could not verify OAuth request". I am doing this with drupal and here is the code I have so far:
$key = "MY_KEY";
$secret ="MY_SECRET";
$timestamp = time();
$nonce = (int) (rand() * 100000000);
$callback = 'http://www.google.com'; //'htt//url('<front>', array('absolute' => TRUE)); //DRUPAL_ROOT . "/toolkittens/git";
$url = "https://bitbucket.org/api/1.0/oauth/request_token";
$data = array(
'oauth_nonce' => $nonce,
'oauth_timestamp' => $timestamp,
'oauth_consumer_key' => $key,
'oauth_signature_method' => 'PLAINTEXT',
'oauth_signature' => 'thisismysig',
'oauth_callback' => $callback,
'oauth_version' => '1.0',
);
$options = array(
'method' => 'POST',
'data' => drupal_http_build_query($data),
'headers' => array('Content-Type' => 'application/x-www-form-urlencoded'),
);
return drupal_http_request($url, $options);
You are providing a PLAINTEXT signature.
If you are requesting a token with the provided signature not encrypted, change your oauth_signature_method to 'PLAINTEXT', so bitbucket knows you didn't encrypt it.
$key = "MY_KEY";
$signature = "MY_SIGNATURE"; //I think this is your secret from bitbucket
$timestamp = time();
$nonce = rand();
$callback = DRUPAL_ROOT . "/toolkittens/git";
$url = "https://bitbucket.org/api/1.0/oauth/request_token";
$data = array(
'oauth_nonce' => $nonce,
'oauth_timestamp' => $timestamp,
'oauth_consumer_key' => $key,
'oauth_signature_method' => 'PLAINTEXT',
'oauth_signature' => $signature,
'oauth_callback' => $callback,
'oauth_version' => '1.0',
);
$options = array(
'method' => 'POST',
'data' => $data,
'headers' => array('Content-Type' => 'application/x-www-form-urlencoded'),
);
$full_url = url($url, array('query' => $data));
return drupal_http_request($full_url);
Also, you defined your options but never used them.
I'm trying to save the display name of a user account using ZfcUser as a base to create my own API, but unfortunately I couldn't. This is my code:
$service = $this->getUserService();
$form = $this->getPostData();
$post = array(
"email" => $form->{'email'},
"password" => $form->{'password'},
"passwordVerify" => $form->{'password'},
"display_name" => $form->{'name'},
"submit" => ""
);
$service->register($post);
return new JsonModel($this->postToArray($form));
I would like to set a query parameter when redirecting. I tried this:
$this->redirect()->toRoute('login/default', array('action' => 'forgotPassword', 'foo' => 'bar'));
It redirects to:
/login/forgotPassword
Instead of where I would like to redirect which is:
/login/forgotPassword?foo=bar
The query parameter belongs to the third parameter of the URL-Methods.
$this->redirect()->toRoute(
'login/default',
array(
'action' => 'forgotPassword'
),
array( 'query' => array(
'foo' => 'bar'
))
)
Plus.
To redirect a "access" or login, form you can use:
if (!$controller->identity()) {
$sm = $controller->getServiceLocator();
$router = $sm->get('router');
$request = $sm->get('request');
$routeMatch = $router->match($request);
$controller->redirect()->toRoute('login', array(),
array( 'query' =>
array('redir' => $routeMatch->getMatchedRouteName() ) ) );
}
Urls will be:
/login/?redir=current-route
In regards to using SOAP to connect to Sugar CRM, the documentation for Sugar 6.1 Community Edition states:
"See /examples/SugarFullTest_Version2.php for more examples on usage."
source:
http://developers.sugarcrm.com/docs/OS/6.1/-docs-Developer_Guides-Sugar_Developer_Guide_6.1.0-Chapter%202%20Application%20Framework.html#9000244
This file is not in the examples folder. Where is it?
If this file does not exist, where can I find a working example of connecting to Sugar CRM with SOAP? None of the test scripts in the /examples/ folder work.
Couldn't find the file either, so made an example (PHP script connecting to sugarCRM v6 SOAP) for you.
<?php
require_once('include/nusoap/lib/nusoap.php');
$myWsdl = 'http://mysite.com/soap.php?wsdl';
$myAuth = array(
'user_name' => 'xxxx',
'password' => MD5('xxxx'),
'version' => '0.1'
);
$soapClient = new nusoap_client($myWsdl,true);
// Create lead
// (Can be made without login, i.e. sessionid)
$leadParams = array('user_name' => 'xxxx',
'password' => MD5('xxxx'),
'first_name' => 'Test',
'last_name' => '2',
'email_address' => '2#'
);
$leadResult = $soapClient->call('create_lead', $leadParams);
$leadId = $leadResult;
print_r($leadResult);
// Login
$loginParams = array('user_auth' => $myAuth, 'application_name' => 'WebForm');
$loginResult = $soapClient->call('login', $loginParams);
$sessionId = $loginResult['id'];
// Modules
// (Need login, so sessionID is used)
$modulesResult = $soapClient->call('get_available_modules', array('session' => $sessionId));
print_r($modulesResult);
// Get account list
$accountParams = array('session' => $sessionId,
'module_name' => 'Accounts',
'query' => "accounts.name = 'Amarelo'",
'order_by' => '',
'deleted' => 0
);
$accountResult = $soapClient->call('get_entry_list', $accountParams);
print_r($accountResult);
// Get entry
$leadParams = array('session' => $sessionId,
'module_name' => 'Leads',
'id' => "$leadId"
);
$leadResult = $soapClient->call('get_entry', $leadParams);
print_r($leadResult);
// Logout
$logoutResult = $soapClient->call('logout', array('session' => $sessionId));
?>
For debugging and testing SoapUI is very helpful.