Bugfix.
--- a/autotweet-php/src/Org/W3/AutotweetBundle/Controller/DefaultController.php Tue Sep 03 19:18:31 2013 +0900
+++ b/autotweet-php/src/Org/W3/AutotweetBundle/Controller/DefaultController.php Tue Sep 03 13:01:21 2013 +0000
@@ -6,48 +6,63 @@
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
class DefaultController extends Controller
{
/**
* @Route("/hello/{name}")
* @Template()
- */
+ */
public function indexAction($name)
{
return array('name' => $name);
//$connection = new \W3TweetTwitterOAuth('hxg6thsXDcNByjBKwGtvdg', 'gJcfbddJPMydmvpaSP3qO283rI257ZtmlbghWjpmB28');
}
+ public function testAction()
+ {
+ return $this->render('OrgW3AutotweetBundle:Default:test.html.twig', array());
+ }
+
public function postAction(Request $request)
{
if ($request->getMethod() == 'POST')
{
-
+/*
foreach ($this->get('request')->request->all() as $key => $val)
{
$data[$key]=$val;
}
- $key=$data['key'];
- $msg=$data['msg'];
+ $key=$data['accesskey'];
+ $msg=$data['note'];
+*/
- //$key=$this->get('request')->request->get('key');
- //$msg=$this->get('request')->request->get('msg');
+ $key=$this->get('request')->request->get('accesskey');
+ $msg=$this->get('request')->request->get('note');
$talk = $this->getDoctrine()->getRepository('OrgW3AutotweetBundle:Talk')->findOneBy(array('key'=>$key));
- $post = $this->getDoctrine()->getRepository('OrgW3AutotweetBundle:Post')->findBy(array('talk' =>$talk, 'content'=>$msg));
- if(0==count($post)){
- $newpost = $this->getDoctrine()->getRepository('OrgW3AutotweetBundle:Post')->addnew($talk,$msg);
- $this->tweet($msg);
+ echo 'Talk:' . count($talk);
+ if(0!=count($talk)){
+ $post = $this->getDoctrine()->getRepository('OrgW3AutotweetBundle:Post')->findBy(array('talk' =>$talk, 'content'=>$msg));
+ echo 'Post:' . count($post);
+ if(0==count($post)){
+ $newpost = $this->getDoctrine()->getRepository('OrgW3AutotweetBundle:Post')->addnew($talk,$msg);
+ $this->tweet($msg);
+ }
}
+
}
- $response->headers->set('Access-Control-Allow-Origin: *');
- return $this->render('OrgW3AutotweetBundle:Default:post.html.twig', array());
+ $content=$this->renderView('OrgW3AutotweetBundle:Default:post.html.twig', array());
+ $response = new Response($content);
+ $response->headers->set('Access-Control-Allow-Origin','*');
+
+ return $response;
}
private function tweet($msg)
{
//set POST variables
$url = 'http://stewgate-u.appspot.com/api/post/';
$fields = array(
- '_t' => urlencode('dd5a674524a1e2d54a7f9a2144ad1ef1'),
+ '_t' => urlencode('af1941d9fa8a8fe12078802ac0d7e26d'),
'msg' => urlencode($msg),
);
$fields_string = '';
--- a/autotweet-php/src/Org/W3/AutotweetBundle/Resources/config/routing.yml Tue Sep 03 19:18:31 2013 +0900
+++ b/autotweet-php/src/Org/W3/AutotweetBundle/Resources/config/routing.yml Tue Sep 03 13:01:21 2013 +0000
@@ -1,3 +1,6 @@
org_w3_autotweet_post:
pattern: /post
- defaults: { _controller: OrgW3AutotweetBundle:Default:post }
\ No newline at end of file
+ defaults: { _controller: OrgW3AutotweetBundle:Default:post }
+org_w3_autotweet_test:
+ pattern: /test
+ defaults: { _controller: OrgW3AutotweetBundle:Default:test }
\ No newline at end of file
--- a/autotweet-php/web/app_dev.php Tue Sep 03 19:18:31 2013 +0900
+++ b/autotweet-php/web/app_dev.php Tue Sep 03 13:01:21 2013 +0000
@@ -1,5 +1,4 @@
<?php
-
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;