First time fatal error lost - php

Hello? Is anybody in there?
I've used this before years ago now I'm back. First time gives me this:
Fatal error: Uncaught Services_Twilio_TinyHttpException in /home/www/skyphilly6.com/twill/twilio-php/Services/Twilio/TinyHttp.php:119 Stack trace: #0 /home/www/skyphilly6.com/twill/twilio-php/Services/Twilio.php(178): Services_Twilio_TinyHttp->__call('post', Array) #1 /home/www/skyphilly6.com/twill/twilio-php/Services/Twilio/ListResource.php(92): Base_Services_Twilio->createData('/2010-04-01/Acc...', Array) #2 /home/www/skyphilly6.com/twill/twilio-php/Services/Twilio/Rest/Calls.php(32): Services_Twilio_ListResource->_create(Array) #3 /home/www/skyphilly6.com/twill/index.php(9): Services_Twilio_Rest_Calls->create('8052629166', '8058130331', 'htttttp://demo.twi...') #4 {main} thrown in /home/www/skyphilly6.com/twill/twilio-php/Services/Twilio/TinyHttp.php on line 119
Here's my short code tried many additional lines same result:
<?php
require('./twilio-php/Services/Twilio.php');
$version = "2010-04-01";
$account_sid = 'ACcfc1ba0d12c58180319486144bef540e'; $auth_token = 'washere';
$client = new Services_Twilio($account_sid, $auth_token, $version);
$client->account->calls- >create('8052629166','8058133333','htttttp://demo.twilio.com/welcome/voice/');
?>
Also tried uncommenting this same result:
<?php
require('./twilio-php/Services/Twilio.php');
$version = "2010-04-01";
//$account_sid = 'SK5b9d2d022b971335e17ee50c813ae231'; $auth_token = 'was';
$account_sid = 'ACcfc1ba0d12c58180319486144bef540e'; $auth_token = 'was';
$client = new Services_Twilio($account_sid, $auth_token, $version);
//try {
//$call=
$client->account->calls->create('8052629166','8058133333','htttttp://demo.twilio.com/welcome/voice/');
//,array(
//'Method' => 'GET',
//'FallbackMethod' => 'GET',
//'StatusCallbackMethod' => 'GET',
//'Record' => 'false', ));
//echo 'Started call: ' . $call->sid;
//} catch (Exception $e) { echo 'Error: ' . $e->getMessage(); }
?>
Please point me in the right direction.
Added:
$http = new Services_Twilio_TinyHttp('https://api.twilio.com',
array('curlopts' => array(
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_SSL_VERIFYHOST => 2,
))
);
//$client = new Services_Twilio($sid, $token, "2010-04-01", $http);
$client = new Services_Twilio($account_sid, $auth_token, $version,$http);
Noticed it doesn't matter what I use for my token same error
Can't find the error log:
$client->http->debug = true;
Hello?

Related

soap not connecting in server PHP

Can anyone plz help
I have written a soap server and a client to test and it works in localhost and also in the server but when both are in save place but when I try to connect the localhost to the server it would not work. gives error
Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in D:\xampp\htdocs\PN Encryptor\service\client.php:9 Stack trace: #0 D:\xampp\htdocs\PN Encryptor\service\client.php(9): SoapClient->__soapCall('hello', Array) #1 {main} thrown in D:\xampp\htdocs\PN Encryptor\service\client.php on line 9
my code
///server
class EncSoapServer
{
public function hello($id){
return "Hello WOrld";
}
}
$options = ['uri' => 'http://prageethniranjan.epizy.com/service'];
$server = new SoapServer(null, $options);
$server->setClass('EncSoapServer');
$server->handle();
/// Client
$client = new SoapClient(null, array(
'location' => "http://prageethniranjan.epizy.com/service/encript.php",
'uri' => "http://prageethniranjan.epizy.com/service",
'trace' => 1 ));
//echo $return = $client->__soapCall("encrypt",array("4.1","this is a text message","Niranjan",1979,8,true));
try{
$responce = $client->__soapCall("hello",array('id'=>1));
echo $responce;
}
catch(SoapFault $e)
{
$response = $client->__getLastResponse();
echo $response;
$response = str_replace("&#x1A",'',$response); ///My Invalid Symbol
$response = str_ireplace(array('SOAP-ENV:','SOAP:'),'',$response);
$response = simplexml_load_string($response);
echo $response;
}
i try running on localhost it works
and put both script on server it also works
but could not connect it with server

Calling web service not working

I trying to call a web service using SOAP protocol with PHP, but it doesn't work.
The url on documentation is:
URL: http://api.teleport.com.br/wsdl/Teleport
My code:
ini_set('soap.wsdl_cache_enabled',0);
ini_set('soap.wsdl_cache_ttl',0);
$url = "http://api.teleport.com.br/wsdl/Teleport";
try {
$client = new SoapClient($url);
$function = 'ConsultaVeiculos';
$arguments= array('ConsultaVeiculos' => array(
"senha" => "*************"
));
$options = array('location' => $url);
$result = $client->__soapCall($function, $arguments);
print_r($result);
} catch (Exception $e) {
print $result." = ".$e;
}
The error:
= SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't find in 'http://api.teleport.com.br/wsdl/Teleport' in PATH: SoapClient->SoapClient('http://api.tele...') #1 [internal function]: FUNCION->testSOAPService() #2 PATH/CodeIgniter.php(359): call_user_func_array(Array, Array) #3 PATH(219): require_once(PATH) #4 {main}
How to correctly do this?
Thanks

Authentication for Slim framework not working

I am using Slim framework to create restful api.
I am able to create a get api, but when I add authentication to the get request, it throws an error(Advanced Rest client google chrome extension), here is the error :
<html><head><title>Slim Application Error</title><style>body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana,sans-serif;}h1{margin:0;font-size:48px;font-weight:normal;line-height:48px;}strong{display:inline-block;width:65px;}</style></head><body><h1>Slim Application Error</h1><p>The application could not run because of the following error:</p><h2>Details</h2><div><strong>Type:</strong> ErrorException</div><div><strong>Code:</strong> 8</div><div><strong>Message:</strong> Undefined variable: apiKey</div><div><strong>File:</strong> /Library/WebServer/Documents/pascal_api/rest_api/v1/index.php</div><div><strong>Line:</strong> 34</div><h2>Trace</h2><pre>#0 /Library/WebServer/Documents/pascal_api/rest_api/v1/index.php(34): Slim\Slim::handleErrors(8, 'Undefined varia...', '/Library/WebSer...', 34, Array)
#1 [internal function]: authenticate(Object(Slim\Route))
#2 /Library/WebServer/Documents/pascal_api/rest_api/libs/Slim/Route.php(433): call_user_func_array('authenticate', Array)
#3 /Library/WebServer/Documents/pascal_api/rest_api/libs/Slim/Slim.php(1307): Slim\Route->dispatch()
#4 /Library/WebServer/Documents/pascal_api/rest_api/libs/Slim/Middleware/Flash.php(85): Slim\Slim->call()
#5 /Library/WebServer/Documents/pascal_api/rest_api/libs/Slim/Middleware/MethodOverride.php(92): Slim\Middleware\Flash->call()
#6 /Library/WebServer/Documents/pascal_api/rest_api/libs/Slim/Middleware/PrettyExceptions.php(67): Slim\Middleware\MethodOverride->call()
#7 /Library/WebServer/Documents/pascal_api/rest_api/libs/Slim/Slim.php(1254): Slim\Middleware\PrettyExceptions->call()
#8 /Library/WebServer/Documents/pascal_api/rest_api/v1/index.php(100): Slim\Slim->run()
#9 {main}</pre></body></html>
Here is my code:
<?php
require '.././libs/Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
function isValidApiKey($api_key) {
$m = new MongoClient();
$db = $m->pascal;
$collection = $db->apiUsers;
if($collection->findOne(array('apiKey' => $api_key))){
return true;
}
else{
return false;
}
}
function authenticate(\Slim\Route $route) {
// Getting request headers
$headers = apache_request_headers();
$response = array();
$app = \Slim\Slim::getInstance();
// Verifying Authorization Header
if (isset($headers['Authorization'])) {
// get the api key
$api_key = $headers['Authorization'];
echo $apiKey;
// validating api key
//$db = new dbSupport();
if ($isValidApiKey($api_key) === false) {
// api key is not present
$response["error"] = true;
$response["message"] = "Access Denied. Invalid Api key";
echoRespnse(401, $response);
$app->halt(401);
}
else{
}
} else {
// api key is missing in header
$response["error"] = true;
$response["message"] = "Api key is misssing";
echoRespnse(400, $response);
$app->halt(401);
}
}
$app->get('/offerData','authenticate',function() use ($app) {
$m = new MongoClient();
$db = $m->pascal;
$collection = $db->offerDetails;
$offer_array = array();
$cursor = $collection->find();
$offer_array["offers"] = array();
foreach ($cursor as $document) {
$offerData = array('title' => $document['title'],
'discription' => $document['discription'],
'create_time' => $document['create_time'],
'expire_time' => $document['expire_time'],
'coordinates' => $document['loc']['coordinates'],
'address' => $document['address'],
'tags' => $document['tags'],
'phone_number' => $document['phone_number'],
'email' => $document['email'],
'website' => $document['website'],
'img_url' => $document['img_url']
);
array_push($offer_array["offers"], $offerData);
}
$offer_array["error"] = false;
echoRespnse(200, $offer_array);
});
function echoRespnse($status_code, $response) {
$app = \Slim\Slim::getInstance();
// Http response code
$app->status($status_code);
// setting response content type to json
$app->contentType('application/json');
echo json_encode($response);
}
$app->run();
?>
Any idea whats causing this error??
Thanks
Please run the print_r command on the $headers and see what are you getting in the there . I think the key is not being set or its not coming at all to your code
Okay then do this before line 28 :
$api_key=null ;
Try this once and let me know .
This is the error :
$api_key = $headers['Authorization'];
echo $apiKey;
But the echo is printing the wrong variable .It should be
echo $api_key;

DailyMotion Invalid authorization code

I'm trying to send videos by DailyMotion PHP SDK with this code:
<?php
require_once 'dailymotion-sdk-php-master/Dailymotion.php';
$api = new Dailymotion();
$api->setGrantType(Dailymotion::GRANT_TYPE_AUTHORIZATION, '081cf3f9d3f64c8d9234', '98da6430d6ebef2621f1061886ecde1a0aa57def', array('manage_videos'));
try
{
$url = $api->uploadFile('video.avi');
$result = $api->call('video.create', array('url' => $url));
}
catch (DailymotionAuthRequiredException $e)
{
// Redirect the user to the Dailymotion authorization page
header('Location: ' . $api->getAuthorizationUrl());
return;
}
catch (DailymotionAuthRefusedException $e)
{
// Handle case when user refused to authorize
// <YOUR CODE>
}
?>
I always get the following error:
Fatal error: Uncaught exception 'DailymotionAuthException' with message 'Invalid authorization code.' in /folder/public_html/dailymotion-sdk-php-master/Dailymotion.php:541 Stack trace:
#0 /folder/public_html/dailymotion-sdk-php-master/Dailymotion.php(370): Dailymotion->oauthTokenRequest(Array)
#1 /folder/public_html/dailymotion-sdk-php-master/Dailymotion.php(247): Dailymotion->getAccessToken()
#2 /folder/public_html/dailymotion-sdk-php-master/Dailymotion.php(203): Dailymotion->call('GET /file/uploa...', Array)
#3 /folder/public_html/dailymotion-sdk-php-master/Dailymotion.php(189): Dailymotion->get('/file/upload')
#4 /folder/public_html/index.php(9): Dailymotion->uploadFile('video.avi')
#5 {main} thrown in /folder/public_html/dailymotion-sdk-php-master/Dailymotion.php on line 541
I've tried the JLepage suggestion( https://stackoverflow.com/questions/12330141/dailymotion-api-invalid-authorization-code ), but without success.
Anyone can help me, please?
I suggest you try this way :
include("Dailymotion.php");
$apiKey = "xxxxxxxxxxxxxxxxxxxx";
$apiSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$username = "yourUsername";
$pwd = "yourPassword";
$filepath = "myVideo.avi";
$api = new Dailymotion();
$api->setGrantType(Dailymotion::GRANT_TYPE_PASSWORD, $apiKey, $apiSecret, array('manage_videos', 'write','delete'), array('username' => $user, 'password' => $pwd));
$url = $api->uploadFile($filePath);
$result = $api->call('video.create', array(
'url' => $url,
'title' => $title,
'description' => $description,
'private' => 'false',
'published' => 'true',
'channel' => 'lifestyle'
));
Important: Don't share your API's ID!
That works for me, hope that work for you too !

Add comment to issue using php and JIRA SOAP API

How do I add a comment to a JIRA Issue using PHP and Jura's SOAP API? I have the connection and tested it retrieving an existing issue, all runs good, but when I try the addComment method it returns this:
Fatal error: Uncaught SoapFault exception: [soapenv:Server.userException] org.xml.sax.SAXException: Bad types (class java.util.HashMap -> class com.atlassian.jira.rpc.soap.beans.RemoteComment) in /home/a7348186/public_html/jira.php:46 Stack trace:
#0 /home/a7348186/public_html/jira.php(46): SoapClient->__call('addComment', Array)
#1 /home/a7348186/public_html/jira.php(46):
SoapClient->addComment('16VGN3ohoo', 'NTP->29', Array)
#2 {main} thrown in /home/a7348186/public_html/jira.php on line 46
This is my code:
<?php
$emailplain = $_REQUEST['plain'];
$emailsubject = $_REQUEST['subject'];
$inputkey = $_REQUEST['key'];
$inputsumm = $_REQUEST['summ'];
$client = new SoapClient(NULL,
array(
"location" => "https://server.com/rpc/soap/jirasoapservice-v2?wsdl",
"uri" => "urn:xmethods-delayed-quotes",
"style" => SOAP_RPC,
"use" => SOAP_ENCODED
));
$token = $client->login("user", "pass");
$issueId = $inputkey;
$issue = $client->getIssue($token, $issueId);
echo("assignee:".$issue->assignee);
echo(" created:".$issue->created);
echo(" summary:".$issue->summary);
echo(" issueid:".$issue->key);
print $inputsumm;
$stringsummary = $issue->summary;
$string = $issue->summary;
$emailsubjectregexp = preg_replace('/[a-zA-Z]+/', '', $inputsumm);
$stringsumm = ('summary ~ "' . $emailsubjectregexp . '"');
$jqlstring = $stringsumm;
$searchjql = $client->getIssuesFromJqlSearch($token, $jqlstring, 100);
function printArray ($array, $devolver = false) {
$stringa = '<pre>' . print_r($array, true) . '</pre>';
if ($devolver) return $stringa;
else echo $stringa;
}
printArray($searchjql);
print_r ($searchjql);
$key = $searchjql[0]->key;
echo $key;
$client->addComment($token, $key, array('body' => 'your comment'));
?>
If you notice, the last line contains the code to execute what I want, but with no luck. Any ideas folks?
Change the way you create the Soap client object, change :
$client = new SoapClient(NULL,
array(
"location" => "https://server.com/rpc/soap/jirasoapservice-v2?wsdl",
"uri" => "urn:xmethods-delayed-quotes",
"style" => SOAP_RPC,
"use" => SOAP_ENCODED
));
to:
$client = new SoapClient("https://jira.watchitoo.com/rpc/soap/jirasoapservice-v2?wsdl");
This should work.
Full add comment code:
$issueKey = "key-123";
$username= "JiraUser";
$password= "JiraPassword";
$jiraAddress = "https://your.jira.com/rpc/soap/jirasoapservice-v2?wsdl";
$myComment = "your comment";
$soapClient = new SoapClient($jiraAddress);
$token = $soapClient->login($username, $password);
$soapClient->addComment($token, $issueKey, array('body' => $myComment));

Categories