$fql_multiquery_url = 'https://graph.facebook.com/'
. 'fql?q={"query1":"SELECT+uid,sex,name,pic_square+FROM+user+WHERE+uid+IN+(SELECT+uid2+FROM+friend+WHERE+uid1=me())+AND+sex=\"'.$sex.'\"","query2":"SELECT+url+FROM+profile_pic+WHERE+id+IN+(SELECT+uid+FROM+#query1)"}'
. '&access_token=' . $access_token;
This gives error
failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request\r\n in /var/www/facebook-php-sdk-master/examples/fqlsample.php on line 82
but the below query works fine.
$fql_multiquery_url = 'https://graph.facebook.com/'
. 'fql?q={"query1":"SELECT+uid,sex,name,pic_square+FROM+user+WHERE+uid+IN+(SELECT+uid2+FROM+friend+WHERE+uid1=me())+AND+sex=\"'.$sex.'\"","query2":"SELECT+url+FROM+profile_pic+WHERE+id+IN+(SELECT+uid2+FROM+friend+WHERE+uid1=me())"}'
. '&access_token=' . $access_token;
the problem is in thhis part
(SELECT+uid+FROM+#query1)
why the multi query fails to work.
any idea?
Related
I tried to make a server file for my ReactPHP app following this video but when I started up the server, it ran successfully, but when I made a simple http GET the response was "Error code
500: Internal server error", when in theory it should've returned a JSON {"message": "Hello"}.
Here is the code for the server.php file:
use React\Http\Server;
use React\Http\Response;
use Psr\Http\Message\ServerRequestInterface;
use \React\EventLoop\Factory;
require 'vendor/autoload.php';
$loop = Factory::create();
$server = new Server(function (ServerRequestInterface $request) {
return new Response(
200, ['Content-Type' => 'application/json'], json_encode(['message' => 'Hello'])
);
});
$socket = new \React\Socket\Server('127.0.0.1:8000', $loop);
$server->listen($socket);
echo "Listening on ".str_replace('tcp', 'http', $socket->getAddress()). PHP_EOL;
$loop->run();
request.http file:
GET 127.0.0.1:8000
What the request has returned:
HTTP/1.1 500 Internal Server Error
Content-Type: text/plain
Server: ReactPHP/1
Date: Fri, 20 Aug 2021 09:03:19 GMT
Content-Length: 32
Connection: close
Error 500: Internal Server Error
Can someone say to me what the problem is? I think I miswrote something in the server.php file but I am not the one to tell
Code you use from a video is a bit outdated.
If you need a quickfix - just replace one line and it will work:
--- use React\Http\Response;
+++ use React\Http\Message\Response;
Working code for this example (as for react/http-1.5.0) would be
use Psr\Http\Message\ServerRequestInterface;
use React\EventLoop\Loop;
use React\Http\HttpServer;
use React\Http\Message\Response;
use React\Socket\SocketServer;
require_once __DIR__ . '/vendor/autoload.php';
$loop = Loop::get();
$server = new HttpServer(function (ServerRequestInterface $request) {
return new Response(
200, ['Content-Type' => 'application/json'], json_encode(['message' => 'Hello'])
);
});
$socket = new SocketServer('127.0.0.1:8000');
$server->listen($socket);
echo 'Listening on ' . str_replace('tcp', 'http', $socket->getAddress()) . PHP_EOL;
$loop->run();
List of changes:
Response class location (actual fix)
loop factory changed, deprecation upFactory::create() -> Loop::get
http-server changed React\Http\Server -> React\Http\HttpServer
socket-server changed React\Socket\Server -> React\Socket\SocketServer
The answer provided by Ilya Urvachev is the right one, basically react evolved and the Response class is not located in the same location anymore.
Overall after instantiating your server I recommend you to use this line of code so you get error messages in your command line interface:
$server->on('error', function (Exception $exception) {
echo $exception->getMessage() . PHP_EOL;
});
All in all, It's been very difficult for me to move from regular PHP to reactphp, which completely destroy the verbosity of error messages. Ie. You've got exception telling you that the format of the answer is not the expected one, while, what really fucks up your code is that have an error in the syntax of one of your MySQL queries, which sends back a message that is not respecting the expecting answer's format. If someone wants to provide additional way to improve the reactphp verbosity, feel free :)
I have created a photoscene in Autodesk Forge. Now I am now trying to upload files to it using this PHP code and my uploads are failing. You can check the urls of the images exist online, are jpgs, and should be acceptable to Forge. (I have also tried uploading them as local files and received the same error messages).
What's preventing Forge from accepting my images, and how do I fix it?
foreach( $files_for_forge as $url )
{
$curl_cmd =
"curl -s $FORGE_URL/photo-to-3d/v1/file " .
"-H 'Authorization: Bearer $access_token' " .
"-d 'photosceneid=$photosceneID' " .
"-d 'type=image' " .
"-d 'file[$filecounter]=$url' "
;
$json = shell_exec ( $curl_cmd );
echo "File $filecounter: $url => $json<br />";
$filecounter++;
}
The resulting output shows every file upload attempt is failing with this error: "Error":{"code":"18","msg":"Specified image protocol is invalid"}
File 0: cloud1.tri-di.com/scans/D-A000-5d008f27/original_images/img-13.jpg => {"Usage":"0.67387795448303","Resource":"\/file","Error":{"code":"18","msg":"Specified image protocol is invalid"}}
File 1: cloud1.tri-di.com/scans/D-A000-5d008f27/original_images/img-22.jpg => {"Usage":"0.70915198326111","Resource":"\/file","Error":{"code":"18","msg":"Specified image protocol is invalid"}}
File 2: cloud1.tri-di.com/scans/D-A000-5d008f27/original_images/img-12.jpg => {"Usage":"0.76431202888489","Resource":"\/file","Error":{"code":"18","msg":"Specified image protocol is invalid"}}
...
File 18: cloud1.tri-di.com/scans/D-A000-5d008f27/original_images/img-20.jpg => {"Usage":"0.74234795570374","Resource":"\/file","Error":{"code":"18","msg":"Specified image protocol is invalid"}}
File 19: cloud1.tri-di.com/scans/D-A000-5d008f27/original_images/img-23.jpg => {"Usage":"0.73936891555786","Resource":"\/file","Error":{"code":"18","msg":"Specified image protocol is invalid"}}
I checked the status of the photoscene with this API call:
curl -s https://developer.api.autodesk.com/photo-to-3d/v1/photoscene/KIpe815PrmsCr1Wp73gMFcXQs9wD27P1n1OLiBNfALU/properties
and it returns the following information about my photoscene, showing no files are being attached:
{
"Usage":"0.70800614356995",
"Resource":"\/photoscene\/KIpe815PrmsCr1Wp73gMFcXQs9wD27P1n1OLiBNfALU\/properties",
"next_token":{},
"Photoscenes":{
"Photoscene:{
"photosceneid":"KIpe815PrmsCr1Wp73gMFcXQs9wD27P1n1OLiBNfALU",
"itemName":"KIpe815PrmsCr1Wp73gMFcXQs9wD27P1n1OLiBNfALU",
"clientID":"HAqDtKO7VbuRgH0nL0MFJ0B02ElBEK3l",
"clientStatus":"CREATED",
"type":"all",
"userID":"DtX37KrG1KKBKOHbphoDMzRfn0k=",
"convertStatus":"CREATED",
"projectID":"KIpe815PrmsCr1Wp73gMFcXQs9wD27P1n1OLiBNfALU",
"engineVersion":"3.0.0.3104",
"convertFormat":"rcm,obj,fbx",
"userAgent":"PF_APIv3.2.473-Photofly-WebAPI-FORGE",
"creationDate":"2019-06-26T22:06:23",
"name":"sonautics-D-A000-5d008f27-20190626150712",
"maxResolutionForImage":"100000000",
"UseTitanTextureEngine":"1",
"scenetype":"object",
"status":"PROCESSING",
"Files":{}
}
}
}
Try again and make sure your URL starts with http or https.
Otherwise our server will not treat them as remote resources and proceed to download.
I'm using PHP curl and it is communicating with the server. I'm trying to get a token. I get the following unhelpful response from the paypal sandbox:
Not Found
The requested URL /cgi-bin/ppapi was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache Server at api.sandbox.paypal.com Port 443
I'm running the code (below) from localhost on my laptop.
/gettoken.php
<?php
//header('Content-Type:application/javascript');
$url = "https://api.sandbox.paypal.com/token";
$client_id = "xxx";
$secret = "xxx";
// Initiate curl
$ch = curl_init();
// set basic auth
curl_setopt($ch,CURLOPT_HTTPAUTH,CURLAUTH_BASIC);
// set user/password
curl_setopt($ch,CURLOPT_USERPWD,$client_id.":".$secret);
// set header accept
$headers = array('Accept:application/json','Accept-Language:en_US');
curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
// set mode to POST
curl_setopt($ch,CURLOPT_POST,1);
// add post fields (1)
$fields_string = "grant_type=client_credentials";
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
// Disable SSL verification
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL,$url);
// Execute
$result=curl_exec($ch);
if($result === false)
{
echo 'Curl error: ' . curl_error($ch);
}
// close curl
curl_close($ch);
// decode result
//var json = json_decode($result, true);
echo('<pre>'.$result.'</pre>');
?>
My apologies, the url to the REST service was wrong.. should have been:
https://api.sandbox.paypal.com/v1/oauth2/token
At least we know that if you get this error that it is likely the REST endpoint url is probably wrong.
I am using crocdoc in php
https://github.com/crocodoc/crocodoc-php
i downloaded the files in my local i had my API TOKEN so i pasted it there but it doesnt seems to work and throws error shown below for all 15 examples
can any one help me here
This is the error here which i am getting on using above github code with my Token
Example #1 - Upload Form W4 from the IRS by URL.
Uploading... failed :(
Error Code: curl_exception
Error Message: Crocodoc: [curl_exception] Crocodoc::_request
{"curl_errno":60,"curl_error":"SSL certificate problem, verify that the CA cert is OK. Details:\nerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed"}
Example #15 - Delete the second file we uploaded.
Deleting... failed :(
Error Code: curl_exception
Error Message: Crocodoc: [curl_exception] Crocodoc::_request
{"curl_errno":60,"curl_error":"SSL certificate problem, verify that the CA cert is OK. Details:\nerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed"}
To check i am using the crocodoc API properly i wrote my own code
this is the error i am getting in my own code
::::OUTPUT::::
{"uuid": "300dc39d-e82b-4d92-a701-b1f376600b96"}
checking status of : {"uuid": "300dc39d-e82b-4d92-a701-b1f376600b96"}
Curl error: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Curl error: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Curl error no: 60
out put for docurlGet is :
bool(false) status is :
Viewing the Document : {"uuid": "300dc39d-e82b-4d92-a701-b1f376600b96"}
this is my code (i am sorry if i am not suppose to paste the whole code but could not understand the whole issue so i am just giving whole code )
<?php
$myToken='gSqV0PpEZhvJfLxQTcuMmoty';
$frameUrl='https://crocodoc.com/api/v2/document/upload';
$api_url = 'https://crocodoc.com/api/v2/';
//curl "https://crocodoc.com/api/v2/document/upload" --data "token=${API_TOKEN}&url=http://web.crocodoc.com/files/test-simple.pdf"
$param='token='.$myToken.'&url=http://web.crocodoc.com/files/test-simple.pdf';
//curl command
$ch = curl_init();
#curl_setopt($ch, CURLOPT_HEADER, 0);
#curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json', 'X-HTTP-Method-Override: POST'));
#curl_setopt($ch, CURLOPT_POST, 1);
#curl_setopt($ch, CURLOPT_URL, $frameUrl);
#curl_setopt($ch, CURLOPT_POSTFIELDS,$param);
#curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
#curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
$uuids = curl_exec($ch);
echo $uuids;
echo "<br>";
echo " checking status of : ", $uuids."<br>";
$status =getStatus($uuids,$api_url,$myToken);
//curl 'https://crocodoc.com/api/v2/document/status?token=F6JOdArWGKmDRlfPQcZna71x&uuids=d5ea0542-baaf-46a1-835c-685a86e70e14'
echo " status is : ", $status."<br>";
echo " Viewing the Document : ", $uuids."<br>";
function getStatus($uuids,$api_url,$myToken){
$isSingleUuid = is_string($uuids);
$obj = json_decode($uuids);
$my_uuid= $obj->uuid;
$url = $api_url.'document/status';
$token = $myToken;
$dataStr = '?token='.$token.'&uuids='.$my_uuid;
$output = my_doCurlGet($url, $dataStr);
var_dump($output);
return $output;
}
function my_doCurlGet($url, $dataStr) {
//var_dump($url.$dataStr);
// var_dump($dataStr);exit;
//
$ch1 = curl_init();
#curl_setopt($ch1, CURLOPT_HEADER, 0);
#curl_setopt($ch1, CURLOPT_HTTPHEADER, array('Accept: application/json', 'X-HTTP-Method-Override: POST'));
#curl_setopt($ch1, CURLOPT_POST, 1);
#curl_setopt($ch1, CURLOPT_URL, $url.$dataStr);
#curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch1);
if(curl_exec($ch1) === false)
{
echo "<br>".'Curl error: ' . curl_error($ch1);
}
else
{
echo "<br>".'Operation completed without any errors'."<br>";
}
//var err_no=curl_errno()
if(curl_errno($ch1))
{
echo "<br>".'Curl error: ' . curl_error($ch1);
echo "<br>".'Curl error no: ' . curl_errno($ch1);
}
echo "<br>". "out put for docurlGet is : $output"."<br>";
return $output;
}
if (curl_errno($ch)) {
print 'An curl error has occurred.';
exit;
}
//var_dump($uuids);
curl_close($ch);
return $uuids;
?>
Thanks for all your help
Curl probably isn't properly configured with a CA bundle, or the configured CA bundle does not include Crocodoc's CA cert.
Check out this answer for more info.
Found the answer
First of all i did enable curl and SSL for beginning but it was not working
i even changed my Localhost name to myHost but it still did not work
so I made few changes in crocodoc.php file which i downloaded from crocodoc api library
CROCODOC PHP LIBRARY
I added this lines and IT WORKED :):):) Thank you all, hope this helps someone else as well.
if(($_SERVER['SERVER_NAME'] == 'myHost') && ($_SERVER['SERVER_ADDR'] == '127.0.0.1') && ($_SERVER['HTTP_HOST'] == 'myHost')) {
$options[CURLOPT_SSL_VERIFYPEER]=false;
}
I need your help.
I am facing a problem using Zend_Service_Yahoo.
I am trying to use Zend_Service_Yahoo. But it shows
"An error occurred sending request. Status code: 404"
$yahoo = new Zend_Service_Yahoo("YAHOO_APPLICATION_ID");
try{
$results = $yahoo->imageSearch('PHP');
foreach ($results as $result) {
echo $result->Title . '<br />';
}
}catch(Exception $e){
echo $e->getMessage();
}
Reference : http://framework.zend.com/manual/1.0/en/zend.service.yahoo.html
Thanks in advance
That's because imagesearch has been deprecated.
We’re shutting down this service in April 2011. For further details, please see the Deprecated Services blog post.