i created my app on fb with permissions ready to publish on users behalf, the thing is, a regular post has Like and Comment links, like buttons on bottom of the post, i want to add my custom link : VOTE NOW, its a poll post
how can i do that?
someone gave an answer but for js sdk not php, n i cant find it on facebook dev documentation
some gave a close enough solution, but ddnt seem to work on php with modifications
FB.ui({
method: "feed",
link: "LINK_URL",
...
actions: [
{ name: "Read Now", link: "URL TO THE READ NOW " }
]
}, function(response) { console.log(response); });
It seems it's working with /me/feed but with my custom /me/xxxxxx:submitted_a_poll/ its not working
When you make a call with the PHP SDK, you also pass a similar set of parameters:
$attachment = array(
'link' => 'http://your-cool-site.com',
'description' => 'This is the description',
...
'actions' => array(
array(
'name' => 'Vote Now!',
'link' => 'http://your-cool-site.com/vote.php'
)
)
);
$result = $facebook->api('/me/feed/', 'post', $attachment);
All you really have to do is add the relevant action settings to your parameters.
Related
I started creating an ajax post form that takes name and email as inputs. The idea is to have the anonymous, un-logged user to fill out the fields, and when the forms posting succeeds on the API, the user gets access to download an eBook.
The admin wants to be able to view the data of all the users that have filled out the form on the backend, so what I did is create a new custom post type labeled "ebook-user".
From the researching that I've done online, it seems that a user could only post on post comments to the rest api. Is there a way to enable anonymous posting on a custom post type?
Right now, when I post with my current code, I get a 401 error:
{
"code": "rest_cannot_create",
"message": "Sorry, you are not allowed to create posts as this user.",
"data": {
"status": 401
}
}
Here's my js code:
fetch(`${site_url}/wp-json/wp/v2/ebook-user`, {
credentials: 'same-origin',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-WP-Nonce': ajax_nonce,
},
body: JSON.stringify(credentials)
})
.then((res) => res.json())
.then((res) => {
console.log(res)
if(res.data.status == 403) {
formMsg.textContent = `Error`
}
console.log('success');
})
.catch((err) => {
console.error(err);
})
Note that I did add this line in my functions.php, which enables comment posting as guest user
add_filter( 'rest_allow_anonymous_comments', '__return_true' );
Since you want to POST with an un-authenticated user, I'd create a custom endpoint to do it.
Something like:
/wp-json/mytld/v1/ebook
Allow POST to the end point but nothing else.
Validate the input VERY CAREFULLY and I'd go so far as to do things like make sure you don't already know the email address before allowing the post to succeed.
This requires a little more code but gives you a lot more control.
=C=
add_action( 'rest_api_init', function () {
register_rest_route( 'getdata/v1', '/author/(?id)', array(
'methods' => 'GET',
'callback' => 'my_bookdata_func',
) );
} );
function my_bookdata_func( $data ) {
$posts = get_posts( array(
'author' => $data['id'],
) );
if ( empty( $posts ) ) {
return null;
}
return $posts[0]->post_title;
}
Url to access
wp-json/getdata/v1/author/(?id).
I am developing a plugin to integrate a payment gateway in WooCommerce. I have done one before.
But in this one, I need to upload a key file in gateway settings and that is used to hash the data before making payment request to related portal.
I have following code which allows to choose file, but I doubt this is working in the back end.
'sandbox_pvt_key' => array(
'title' => __( 'Test Private Key', 'woocommerce-custom-gateway' ),
'type' => 'file',
'desc_tip' => true,
'description' => __( 'Please upload the test private key file; this is needed in order to test payment.', 'woocommerce-custom-gateway' ),
'default' => '',
),
The output looks like the following:
Can anybody lemme know if this is supported option in the gateway settings? If not, can anybody guide me on how I can customize it via some hook/filters or any other way.
This can be achieved in the process_admin_options()
public function process_admin_options() {
$this->upload_key_files();
$saved = parent::process_admin_options();
return $saved;
}
private function upload_key_files() {
//handle uploads here
}
I want to include notifications, e.g. for forum threads. A user shall retrieve notifications if there are any new posts to a forum thread. Another example would be the notifications on Facebook, e.g. where you're notified of new comments on your posts or pictures.
Is there a notification bundle for Symfony2 that you can recommend for implementing such a function?
I came up with the Sonata NotificationBundle but I am unsure if this is what I really need. When I look at the usage examples it looks as if this would provide a email notification function
// retrieve the notification backend
$backend = $container->get('sonata.notification.backend');
// create and publish a message
$backend->createAndPublish('mailer', array(
'from' => array(
'email' => 'no-reply#sonata-project.org',
'name' => 'No Reply'
),
'to' => array(
'myuser#example.org' => 'My User',
'myuser1#example.org' => 'My User 1',
),
'message' => array(
'html' => '<b>hello</b>',
'text' => 'hello'
),
'subject' => 'Contact form',
));
or a logging function
$this->get('sonata.notification.backend')->createAndPublish('logger', array(
'level' => 'debug',
'message' => 'Hello world!'
));
Can you confirm/recommend the usage of that bundle? Or can you recommend any other?
Good news:
NotificationBundle from GeniusesOfSymfony
https://github.com/GeniusesOfSymfony/NotificationBundle
Proper documentation will probably be published soon.
(on-going discussion here: https://github.com/GeniusesOfSymfony/WebSocketBundle/issues/4#issuecomment-81829513)
I've already tested a similar bundle created by them (WebSocketBundle) which also provides real-time-interaction and it works really great. The documentation is also very good.
I recommend that you "star" the project on github. You can also create an issue to ask about the current status of the project.
I'm searching for the same library now, and also found https://github.com/namshi/notificator
Didn't use it yet, but it has 130 stars today, so probably will try it.
You can achieve this with sonata notification bundle.
You will need to create custom consumer class as described here
https://sonata-project.org/bundles/notification/3-x/doc/reference/usage.html#custom-consumer
You can try this Bundle: NotificationsBundle
It's a simple implementation for Pusher that provides a real time data proadcast.
i want to place the following codes into include/mail.inc of Drupal7 so that i can send mail from SourceForge's project web space. Don't ask me to install SMTP Authentication Support, and i don't have access to php.ini , I wonder where should these codes be placed? Thanks in advance!
include('Mail.php');
$recipients = array( 'someone#example.com' ); # Can be one or more emails
$headers = array (
'From' => 'someone#example.com',
'To' => join(', ', $recipients),
'Subject' => 'Testing email from project web',
);
$body = "This was sent via php from project web!\n";
$mail_object =& Mail::factory('smtp',
array(
'host' => 'prwebmail',
'auth' => true,
'username' => 'YOUR_PROJECT_NAME',
'password' => 'PASSWORD', # As set on your project's config page
#'debug' => true, # uncomment to enable debugging
));
$mail_object->send($recipients, $headers, $body);
if this code could success send email without drupal7 (you must make sure it)
then you could do it in three ways:
write a drupal 7 module ,copy mail.php into *.module, and make the rest code as a function,that's the way as the handbook of drupal.
just copy all of the code to you theme/page.tpl.php , and run it directly , a little dirty
hack drupal core , include/mail.inc , just change function drupal_mail_send
Can anyone help me with drupal mimemail for attachment i am using below mentioned code to send attachment file on specific email, but somehow its not working, kinldy help me thanks in advance
$body = "test body with attachments";
$subject = "My test message";
$attachments[]=array(
'filepath' => file_directory_path().'/document.pdf',
'filename' => 'wonderful.pdf',
'filemime' => 'application/pdf',
);
mimemail("xxxxx#gmail.com", "xxxxxx2#gmail.com", $subject, $body, NULL, array(), NULL, $attachments,'');
I'm doing something very similar. My code is basically:
$message['attachments'][] = array(
'filepath' => $zipfilepath,
'filename' => 'my-attachment.zip',
'filemime' => 'application/zip',
);
from within my hook_mail module callback. See http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_mail/6
Are you sure that you've done the following:
enabled "mimemail" module;
checked the option in admin to "Use mime mail for all messages";
selected "mimemail" as the "E-mail Engine" (at the bottom of the admin page).
Mine is working just fine. I have SMTP module installed as well, and it works with either module selected as the Email Engine.