I am trying to delete an page tab app that i have installed on a page using the graphAPI.
I think i am close.
here is where i am ( will try to remove fluff)
i have my pageID $pageID
$page_info = $facebook->api("/".$pageID."?fields=access_token");
if( !empty($page_info['access_token']) ) {
$args = array(
'access_token' => $page_info['access_token']
);
$pageAccessToken = $page_info['access_token'];
}
$result = $facebook->api('/'.$pageID.'/tabs/'.FB_APP_ID,
'delete',
array('access_token' => $pageAccessToken));
but i get the error"
Tab is not installed or not removable: Exception-->[(#100) Tab is not installed or not removable:
Thanks for any help
found my problem
'/'.$pageID.'/tabs/'.FB_APP_ID
should have been
'/'.$pageID.'/tabs/app_'.FB_APP_ID
I was mising the app_ after /tabs/
Related
i'm working with Drupal 8, and i'm trying to receive a get variable called id, the url looks like http://localhost/drp/listado/editar/2.
this is the function in the controller
public function edit(Request $request){
$id = $request->query->get('id');
$conexion = \Drupal::database();
$query = $conexion->query("Select * from node where nid = ".$id);
$result = $query->fetchAll();
return array(
'#id' => $id,
'#datos' => $result,
'#theme' => 'editar',
'#titulo' => 'Editar'
);
}
but i get this error in reports/dblogs
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1: Select * from node where nid =;
this is the custom_controller.routing.yml
custom_controller.editar:
path: '/listado/editar/{id}'
defaults:
_controller: '\Drupal\custom_controller\Controller\ListController::edit'
_title: 'Edit'
requirements:
_permission: 'access_content'
it's not getting the value of the variable, any help is welcome, thanks
I think the first parameter your controller is receiving is id, the second parameter is request which is automatic. See here https://www.drupal.org/docs/8/api/routing-system/using-parameters-in-routes
Maybe you can print the contents of the first parameter and die() to check what value Drupal is passing.
Install devel module first and dump $request variable. After hitting url you can get id Parameter.
I have request like this:
$path = storage_path('testing/unnamed.png');
$original_name = 'unnamed';
$mime_type = 'image/png';
$size = 2192;
$error = null;
$test = true;
$file = new UploadedFile($path, $original_name, $mime_type, $size, $error, $test);
$response = $this->call('POST', 'games', [
'name' => 'TEST321',
'category' => 'test',], [], ['picture' => $file], []);
And insted of storing image how can I mock file system?
Also this don't pass laravel mime validation mimes:jpeg,bmp,png... Anyone know how to fix it?
laravel allows you to mock any facade by calling the 'shouldReceive' mockery method on it:
File::shouldReceive('move')
->with('arguments');
see the docs for more information
I wrote and use a Laravel 5.4 package, https://packagist.org/packages/stechstudio/laravel-vfs-adapter to let me easily switch to a Virtual File System adapter.
I'm developing a plugin that lets me add and delete custom table records. Adding and deleting records works fine.
I also want to be able to update the records. This is where I cannot figure out what I'm doing wrong.
Here is my update code if anyone can point me in the right direction (I'm currently focused on the "update selected record" script:
function url_update() {
global $wpdb;
$id = $_GET["id"];
$launchname=$_POST["launchname"];
$url1 = $_POST["url1"];
$url2 = $_POST["url2"];
$urluser = $_POST["urluser"];
$urlpwd = $_POST["urlpwd"];
$wpfirstname = $_POST["wpfirstname"];
$wplastname = $_POST["wplastname"];
$wpemail = $_POST["wpemail"];
$activated = $_POST["activated"];
//update selected record
if(isset($_POST['update'])){
$wpdb->update('launcher',
array(
'id' => $id,
'launchname' => $launchname,
'url1' => $url1,
'url2' => $url2,
'urluser' => $urluser,
'urlpwd' => $urlpwd,
'wpfirstname' => $wpfirstname,
'wplastname' => $wplastname,
'wpemail' => $wpemail,
'activated' => $activated
),
array( 'ID' => $id ), //this line fixed the issue
array('%d','%s','%s','%s','%s','%s','%s','%s','%s','%s'));
}
//delete
else if(isset($_POST['delete'])){
$wpdb->query($wpdb->prepare(
"DELETE FROM wp_tincan_launcher WHERE id = %d",$id
));
}
else{
//selecting row to update
$selected_record = $wpdb->get_results($wpdb->prepare(
"SELECT id,launchname,url1,url2,urluser,urlpwd,wpfirstname,
wplastname,wpemail,activated from launcher where id=%d",$id
));
foreach ( $selected_record as $s ){
$launchname=$s->launchname;
$url1=$s->url1;
$url2=$s->url2;
$urluser=$s->urluser;
$urlpwd=$s->urlpwd;
$wpfirstname=$s->wpfirstname;
$wplastname=$s->wplastname;
$wpemail=$s->wpemail;
$activated=$s->activated;
}
}
I think my code is correct, however, I would really appreciate some feedback that directly addresses my code.
EDIT: Thanks to Pekka for pointing out that I did not identify the error results.
The Error I'm getting from WP is "Notice: Undefined index: each column in the DB."
Best Regards
I resolved it myself by changing my update query to include a new line as follows: array( 'ID' => $id ), before the types line.
None of the links I was led to, not any of the generic advice I was provided was of any help what-so-ever.
I've edited the original code to reflect the complete working code.
opencart 1.5.5.1 how change on normal link? See on picture http://i.imgur.com/H9krDbT.jpg
link in administration order to edit items (admin/index.php?route=catalog/product/update&token=4d93b21563db6a6c5fe44b7c365c210b&product_id=54), this is bad, how change on normal link (index.php?route=product/product&product_id=54)
$action = array();
$action = array(
'text' => [[Pass_text_value]],
'href' => $this->url->link('catalog/product/update', 'token=' . $this->session->data['token'] . '&product_id=' . [[Pass_product_id_here]] . $url, 'SSL')
);
See this is the only way you should pass actions like EDIT from the controller to template. The whole link will not be displayed but only the passed text.
If you are passing more than one instances to template then put these whole code inside your foreach loop and change $action = array( to $action[] = array(.
I am busy with a site built on Code Igniter that needs integration with Prestashop. In the site, when creating a user account, I save a "shop_id" to the database, which is then retrieved as a session variable when logging in.
I am using the Prestashop API to retrieve the customer successfully (using above "shop_id")
$xml = $this->PSWebService->get(
array('resource' => 'customers', 'id' => (int)$this->user['shop_id'])
);
This successfully returns the user in question, but there is no Cart IDs in this result.
Logging in to the back-end of my shop, I see that there are multiple carts associated with the logged in user.
My question is: How to I retrieve the LATEST cart ID using the API?
$userId = (int) $this->user['shop_id'];
$opt['resource'] = 'carts';
$xml = $this->PSWebService->get($opt);
$carts = $xml->carts->children();
foreach ($carts as $cart) {
$cartIds[] = $cart['id'];
}
for ($i = count($cartIds) - 1; $i > -1; $i--) {
$opt['id'] = $cartIds[$i];
$xml = $this->PSWebService->get($opt);
//since cart ids are descending the first found will be the latest
if ($xml->cart->id_customer == $userId) {
$latestCartId = $cartIds[$i];
break;
}
}
Kind of late, but I struggled a bit with this same problem and found a way to do it just from query, based on yenshirak's tip (since cart ids are descending the first found will be the latest).
I query the API directly using postman like this:
get all carts:
GET webserver/api/carts
get cart for customer:
GET webserver/api/carts?filter[id_customer]=1
get the most recent:
GET webserver/api/carts?filter[id_customer]=1&sort=[id_DESC]&limit=1
for a pretty print, you can also add params:
display=full&output_format=JSON
You can do this in php, I have not tested if the syntax is correct, but based on documentation it looks something like this:
$opt = array(
'resource' => 'carts',
'filter[id_customer]' => '[1]',
'sort' => '[id_DESC]',
'limit' => '1'
);
$xml = $webService->get($opt);